Hello everyone, this is my first post on stackoverflow. I have encountered an issue in my code that is causing an error which reads like this:
TypeError: Cannot read property 'goals' of undefined
at $scope.addValue.$modal.open.resolve.goals (app.js:59) at Object.invoke (angular.js:3762) at ui-bootstrap-tpls-0.12.1.js:2118 at Object.forEach (angular.js:329) at getResolvePromises (ui-bootstrap-tpls-0.12.1.js:2116) at Object.$modalProvider.$get.$modal.open (ui-bootstrap-tpls-0.12.1.js:2151) at Scope.$scope.addValue (app.js:53) at Parser.functionCall (angular.js:10294) at angular.js:18229 at Scope.$get.Scope.$eval (angular.js:12075)
In my code, 'goals' is similar to 'items' in some other code I saw.
The error is originating from the ctrlAddValue controller where there is a reference to 'goals': function($scope, $modalInstance, goals)
If anyone has any insights or solutions, I would greatly appreciate it!
Here is the portion of the code causing the problem:
app.controller("ctrlCtx", function ($scope, $state, $stateParams, $modal, $window) {
$scope.goals = "A good 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 section shows the code for the 'ctrlAddValue' controller.
app.controller('ctrlAddValue', function ($scope, $state, $modalInstance, goals) {
$scope.addValue = function(){
$modalInstance.close();
};
$scope.cancel = function () {
$modalInstance.dismiss();
};
});
This code snippet is based on the ui.bootstrap demo for modals.