Modal service in angularJS

Below is my controller

angular.module('repoApp')
  .controller('loginCtrl', function ($scope,$modal,$state) {
    $scope.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];

    $modal.open({     
      templateURL: 'views/modals/test.html',      
    });  
  });

      

Below is my template:

<div class="modal-header">
            <h3 class="modal-title">I'm a modal!</h3>
        </div>

      

Error: I got:

Error: One of template or templateUrl options is required.
    at Object.$modalProvider.$get.$modal.open (http://localhost:9000/bower_components/angular-bootstrap/ui-bootstrap-tpls.js:2353:21)
    at new <anonymous> (http://localhost:9000/scripts/controllers/login/loginCtrl.js:18:12)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4203:17)
    at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4211:27)
    at http://localhost:9000/bower_components/angular/angular.js:8501:28
    at link (http://localhost:9000/bower_components/angular-route/angular-route.js:975:26)
    at invokeLinkFn (http://localhost:9000/bower_components/angular/angular.js:8258:9)
    at nodeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7768:11)
    at compositeLinkFn (http://localhost:9000/bower_components/angular/angular.js:7117:13)
    at publicLinkFn (http://localhost:9000/bower_components/angular/angular.js:6996:30) <div ng-view="" class="ng-scope">

      

This code doesn't open the template, but when I use "template" and paste the template there, it appears. This URL template will not run. I have configured my grunt file, but I'm not sure if there are any changes there. Do I need to include lib in index.html?

+3


source to share


1 answer


You didn't really provide a template for the modal because it should be templateUrl

, not templateUrl

.

This should work:



$modal.open({     
  templateUrl: 'views/modals/test.html',      
});

      

+5


source







All Articles