[英]how to use angular-ui modal templateURL with node/express routing
I'm somewhat confused as to why I get this error. 我有点困惑为什么我得到这个错误。 I have a hunch it's with the templateURL and I have tried a few things but to no avail.
我有一个预感,它与templateURL有关,我尝试过一些东西,但无济于事。 I have read the documentation and scoured a bunch of SO posts but none of them helped much.
我已经阅读了文档,并搜索了一堆SO帖子,但没有一个帮助太多。 I want to use Express/Node to serve up the pages and I have a feeling that's why my templateURL isn't working in app.js.
我想使用Express / Node来提供页面,我有一种感觉,这就是为什么我的templateURL无法在app.js中运行。
Here is my index.html with my controller and my template. 这是我的index.html与我的控制器和我的模板。
<body ng-app="app" ng-controller="AppCtrl">
<script type="text/ng-template" id="pageContent.html">
<div class="container">
<div class="modal-header">
<h3 class="modal-title">I am a modal!</h3>
</div>
<div class="modal-body">
<h1>HELLO</h1>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="cancel()">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
</div>
</script>
<div ng-click="open()"> <!-- this is what makes the modal -->
<!-- rest of html below -->
This is what is in app.js 这就是app.js中的内容
var app = angular.module("app", ["ngAnimate", 'ui.bootstrap']);
app.controller("AppCtrl", function($scope, $timeout, $uibModal, $http) {
$scope.open = function (person) {
$scope.selectedPerson = "passed in person";
console.log($scope.selectedPerson);
var modalInstance = $uibModal.open({
templateUrl: 'pageContent.html',
controller: 'ModalInstanceCtrl',
resolve: {
selectedPerson: function() {
return $scope.selectedPerson;
}
}
});
};
});
app.controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, selectedPerson) {
$scope.selectedPerson = selectedPerson;
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
});
I have also tried to replace templateURL with template: "<p> hello world </p>"
but that also produces same error. 我还尝试用
template: "<p> hello world </p>"
替换templateURL template: "<p> hello world </p>"
但这也会产生相同的错误。
Use angular.js
instead of angular.min.js
to get a clearer error message. 使用
angular.js
而不是angular.min.js
来获得更清晰的错误消息。
To resolve this particular problem, you need to use ui-bootstrap-tpls.min.js
(or ui-bootstrap-tpls.js
) instead of ui-bootstrap.min.js
( ui-bootstrap.js
). 要解决此特定问题,您需要使用
ui-bootstrap-tpls.min.js
(或ui-bootstrap-tpls.js
)而不是ui-bootstrap.min.js
( ui-bootstrap.js
)。
After that, you probably have some other issues, but maybe that is then a different SO Question? 在那之后,你可能还有其他一些问题,但也许这是一个不同的SO问题? :-)
:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.