Angular-ui modal issue
I'm trying to include an angular-ui modal in my web application but am
having issues with getting everything set up.
The documentation indicate that you can use $modalInstance to inject the
child controller into the parent controller but I don't quite understand
how to go about doing so.
Here is the current code (it is straight from the modal demo from the
documentation):
angular.module('myApp.controllers', []).
controller('addContent', function ($scope, $http, $modal, $log){
//modaltest
$scope.items = ['item1', 'item2', 'item3'];
$scope.addTerm = function () {
var newTerm = $modal.open({
templateUrl: 'newTermModal.jade',
controller: newTerms,
resolve: {
items: function () {
return $scope.items;
}
}
});
newTerm.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
}).
controller("newTerms",function($scope, $modalInstance, items){
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function () {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
});
When I run the app like it is now and click the button to open the modal
(addTerm function) the app crashes with the error "ReferenceError:
newTerms is not defined."
As I mentioned above, the angular-ui site indicates you can inject a
controller with $modalInstance but I have not been able to figure out how.
a Any help would be greatly appreciated!
No comments:
Post a Comment