admin管理员组文章数量:1290963
I have 2 layout files. Layout-1 Layout-2
The route /one
is the starting point which loads the Layout-1
, but now if I click on a link /two
it gets me the file, but with Layout-1
, instead i want, if i hit /two
, Layout-2
should be loaded.
If i refresh the page, i get the correct thing coz that time i hit the server directly. So is there any way from angular to specify which layout file to load from Server.
Thanks.
I have 2 layout files. Layout-1 Layout-2
The route /one
is the starting point which loads the Layout-1
, but now if I click on a link /two
it gets me the file, but with Layout-1
, instead i want, if i hit /two
, Layout-2
should be loaded.
If i refresh the page, i get the correct thing coz that time i hit the server directly. So is there any way from angular to specify which layout file to load from Server.
Thanks.
Share Improve this question asked Jun 24, 2013 at 10:50 Aamir ShahAamir Shah 4,4938 gold badges22 silver badges28 bronze badges 2- 1 use ng-view with $routeprovider to configure routes bunch of examples are available online – Ajay Singh Beniwal Commented Jun 24, 2013 at 11:06
- 2 i couldn't find any example where in i can have templates rendered inside different LAYOUT files. – Aamir Shah Commented Jun 24, 2013 at 11:33
3 Answers
Reset to default 1Loading new layout template means loading new html embedded with new javascript and css files.
This is equal to redirecting page to new location. You can use $window.location.href="new/layout/template"
. Read angularjs developer guide for more info.
If it stands for client side routing then you should use $routeProvider to write a route for this
var app = angular.module('app', []);
app.config(function($routeProvider){
$routeProvider
.when('/one', {templateUrl: 'tmpl1.html'})
.when('/two', {templateUrl: 'tmpl2.html'})
.otherwise({redirectTo: '/one'});
});
It will allow you to define separate template and controller for another url/action
Here I made a working example of how it work.
If it is about serverside routing then read manual and use it like this:
match 'two' => 'controller#action'
Finally, i got the problem solved using UI-Router
Thanks for the help :)
本文标签: javascriptHow to load a different layout in angularjsStack Overflow
版权声明:本文标题:javascript - How to load a different layout in angularjs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741509643a2382532.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论