[英]How structure my angularjs app
I don't know how to "include" partials on templates. 我不知道如何在模板上“包含”局部。 For example, I've an template "index".
例如,我有一个模板“ index”。 When the user navigate to "/" I like re render some divs on "index" from partials (login box and some others text div), when de user navigate to "/newAccount" I like re render same divs on "index" but with others partials.
当用户导航到“ /”时,我喜欢从局部(登录框和其他一些文本div)重新呈现“索引”上的一些div,当用户导航到“ / newAccount”时,我喜欢在“ index”上重新呈现相同的div,但是与其他人的偏见。
The question is, it's the correcly way to use of AngularJS? 问题是,这是使用AngularJS的正确方法吗? Similar to the includes on Facelets?
与Facelets上的include类似吗?
Thanks! 谢谢! ;)
;)
Here a pseudo code of my idea: 这是我的想法的伪代码:
Template: 模板:
<html>
<body>....{include:mainBox}....{include:foot}...</body>
</html>
Partials for /newAccount: / newAccount的部分:
{define mainBox} {定义mainBox}
<div>New user</div>
<div>Username:<input/></div>
{define foot} {定义脚}
<div>...</div>
Update: 更新:
Some like this is wrong? 像这样的人错了吗?
function IndexCtrl($scope) {
$scope.mainPage = 'partials/index/loginbox.html',
$scope.footPage = 'partials/index/footer.html',
}
After in the template I put: 在模板中之后,我输入:
<div ng-include="mainPage"></div>
...
<div ng-include="footPage"></div>
And the route: 路线:
when('/', {
templateUrl: 'partials/index/layout.html',
controller: IndexCtrl
})
Use ng-include for this. 为此使用ng-include 。 Maybe what you want is ng-view + $routeProvider
也许您想要的是ng-view + $ routeProvider
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.