gpt4 book ai didi

angularjs - AngularJS 中的模态服务

转载 作者:行者123 更新时间:2023-12-02 23:55:28 25 4
gpt4 key购买 nike

下面是我的 Controller

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

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

下面是我的模板:

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

我得到的错误是:

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">

这段代码没有打开模板,但是当我使用"template"选项并在那里插入模板标记时,它就会显示出来。此 templateURL 未被触发。我已经配置了 gruntfile,但我不确定是否还需要进行任何更改。index.html 中是否需要包含任何库?

最佳答案

您确实没有为模式提供任何模板,因为它应该是 templateUrl,而不是 templateURL

这应该有效:

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

关于angularjs - AngularJS 中的模态服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30365656/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com