I am trying to incorporate angular -ui modal in my web application, but I am having setup problems.
The documentation states that you can use $ modalInstance to enter the child controller into the parent controller, but I do not quite understand how to do this.
Here is the current code (directly 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 launch the application as it is now and press the button to open the modal function (addTerm), the application crashes with the error "ReferenceError: newTerms not defined".
As I mentioned above, the angular -ui site indicates that you can enter the controller using $ modalInstance, but I could not figure out how to do this. Any help would be greatly appreciated!
EDIT
After adding quotes in the path suggested by Chandermani, it seems that the modal loading is on the current page, and not in the specified template.
I changed the path to the following: templateUrl:
$scope.addTerm = function () { var newTerm = $modal.open({ templateUrl: './views/partials/newTermModal.jade', controller: 'newTerms', resolve: { items: function () { return $scope.items; } } });
Below is a screenshot:
Any idea what could be causing this?