javascript - angularJS resolve: in controller "Cannot read property 'goals' of undefined -
this first question on stackoverflow. ( know struggled lot quotes..) stuck problem snippet of following code leaves me following error:
typeerror: cannot read property 'goals' of undefined
@ $scope.addvalue.$modal.open.resolve.goals (app.js:59) @ object.invoke (angular.js:3762) @ ui-bootstrap-tpls-0.12.1.js:2118 @ object.foreach (angular.js:329) @ getresolvepromises (ui-bootstrap-tpls-0.12.1.js:2116) @ object.$modalprovider.$get.$modal.open (ui-bootstrap-tpls-0.12.1.js:2151) @ scope.$scope.addvalue (app.js:53) @ parser.functioncall (angular.js:10294) @ angular.js:18229 @ scope.$get.scope.$eval (angular.js:12075)
'goals' in code equivalent of 'items' in 'inspired by" code.
this message seems come ctrladdvalue controller includes 'goals' reference: function($scope, $modalinstance, goals)
thanks help!
the culprit:
app.controller("ctrlctx", function ($scope, $state, $stateparams, $modal, $window) { $scope.goals = "a goal"; $scope.addvalue = function (size, $scope) { var modalinstance = $modal.open({ templateurl: 'templates/addvalue.html', size: "lg", controller: "ctrladdvalue", resolve: { goals: function () { return $scope.goals; } } }) modalinstance.result.then( function (selecteditem) { }, function () { }); }; }); this 'ctrladdvalue' controller code.
app.controller('ctrladdvalue', function ($scope, $state, $modalinstance, goals) { $scope.addvalue = function(){ $modalinstance.close(); }; $scope.cancel = function () { $modalinstance.dismiss(); }; }); this based on ui.bootstrap demo modal.
app.controller("ctrlctx", function ($scope, $state, $stateparams, $modal, $window) { $scope.goals = "a goal"; $scope.addvalue = function (size, $scope) { you passing $scope local parameter , calling function $scope.addvalue(something); making local $scope undefined.
remove $scope parameter addvalue function.
Comments
Post a Comment