我正在使用引导程序来显示模式,并希望在单击锚标记时将其显示为路线。
但我遇到模块错误并且似乎不知道如何解决它。
HTML
<div ng-view>
<div ng-controller="DetailPageCtrl">
<a href="#/profile">Click here to open modal!</a>
</div>
<script type="text/ng-template" id="modalContainer">
<div ng-controller="ProfileModalCtrl"></div>
</script>
</div>
JS
var app = angular.module('plunker', ['ui.bootstrap']);
app.config(function($routeProvider) {
$routeProvider
.when('/profile', {
templateUrl : 'modalContainer',
controller : 'ProfileModalCtrl'
});
})
app.controller('DetailPageCtrl', function($scope) {
console.log("detail page");
});
app.controller('ProfileModalCtrl', function($scope, $modal) {
$modal.open({templateUrl : 'modal.html'});
});
plnkr 中的代码:http://plnkr.co/edit/VbvuWzLqkICFzBYI9sL5?p=preview http://plnkr.co/edit/VbvuWzLqkICFzBYI9sL5?p=preview
演示充满了问题。您还没有包含 angular-route.js。您没有使用提供默认路径otherwise
并且您将 html 放入其中ng-view
/* include script tag with `angular-route.js , then inject as dependency*/
var app = angular.module('plunker', ['ui.bootstrap', 'ngRoute']);
app.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'default'
})
.when('/profile', {
templateUrl: 'modalContainer',
controller: 'ProfileModalCtrl'
}).otherwise({
redirectTo: '/'
})
});
<div ng-view><!-- leave empty --></div>
DEMO http://plnkr.co/edit/33572YOSA2s89uEiLmKB?p=preview
您也会遇到声明相同的问题ng-controller
在路由配置中的标记中...选择一个或另一个
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)