javascript - Error with ngDialog -
i'm using ngdialog project in order display popup on website. downloaded project zip github, comes examples data, works , when work external templates , controller doesn't work .. search solutions on seems forget include ngdialog not case (if dumbest person on earth)
here code :
in index.html :
<html lang="en" ng-app="blackoutapp"> ... <div id="body" ng-view></div>
in controllers.js file :
var blackoutapp = angular.module('blackoutapp', ['ngroute', 'ngdialog']); blackoutapp.config(['$routeprovider', 'ngdialogprovider', function($routeprovider, ngdialogprovider) { $routeprovider.when('/', { templateurl: 'templates/body.tpl.html', controller: 'bodyctrl' }); ngdialogprovider.setdefaults({ classname: 'ngdialog-theme-default', plain: false, showclose: true, closebydocument: true, closebyescape: true, appendto: false, preclosecallback: function () { console.log('default pre-close callback'); } }); }]); blackoutapp.controller('openctrl', ['$scope', function ($scope) { $scope.name = "popup"; }]); blackoutapp.controller('bodyctrl', ['$scope', function ($scope, $rootscope, ngdialog) { $scope.menus = [ {'link' : '#/', 'name' : 'main'}, ]; $scope.videobuttons = [ {'class' : 'tubular-play', 'name' : 'play'}, {'class' : 'tubular-pause', 'name' : 'pause'}, ]; $scope.open = function () { ngdialog.open({template: 'templates/popup.tpl.html', controller: 'openctrl'}); }; }]);
and bdoy.tpl.html :
<div class="container"> <div class="grid"> <div class="center" id="coverevent"></div> <div class="center"><a id="mapinfo" class="active" href="#"></a></div> <div> <a href="" ng-click="open()">open via service</a> </div> </div> </div>
all scripts included @ end of index.html body tag. when click on link open via service
got error :
typeerror: cannot read property 'open' of undefined @ k.$scope.open (http://nico.local:5757/blackout/js/controllers.js:36:13) @ http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:177:68 @ f (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:194:174) @ k.$eval (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:112:68) @ k.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:112:346) @ htmlanchorelement.<anonymous> (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js:194:226) @ htmlanchorelement.p.event.dispatch (http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js:2:37944) @ htmlanchorelement.g.handle.h (http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js:2:33888)
replace 'bodyctrl' this:
blackoutapp.controller('bodyctrl', 'ngdialog', ['$scope', function ($scope, $rootscope, ngdialog) { $scope.menus = [ {'link' : '#/', 'name' : 'main'}, ]; $scope.videobuttons = [ {'class' : 'tubular-play', 'name' : 'play'}, {'class' : 'tubular-pause', 'name' : 'pause'}, ]; $scope.open = function () { ngdialog.open({template: 'templates/popup.tpl.html', controller: 'openctrl'}); }; }]);
Comments
Post a Comment