目前我正在像今天这样在我的 index.html 文件中使用 ng-template
,
<script type="text/ng-template" id="/home.html">
//html here...
</script>
我也在使用 ui.router,它看起来像这样,
$stateProvider
.state('home', {
url: '/home',
templateUrl: '/home.html',
controller: 'mainController',
resolve: {
postPromise: ['serv', function(serv) {
return serv.getAll();
}]
}
});
这很好用。
问题是我想扩展我的应用程序并了解更多关于最佳实践以及如何实际使用 Angular 信息。我的背景是 .NET MVC,其中有主视图/ View /部分 View 。所以我试图在这里用 Angular 做同样的方法,但在我的例子中,我将 index.html
作为主控,而 home.html
将是 View 或部分如果你愿意的话。感谢我收到的所有意见。
最佳答案
这确实是一种类似的方法——至少在 angular 1.x 中是这样(还没有深入研究 2)。 :)
我在调查这个问题时遇到的两个很好的来源是:
它们应该共同指向正确的方向。
关于javascript - 带有 ui.router 的 ng-template,单独的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36336147/