如何使用Angular js在多页面应用程序中制作两个不同的标题?

时间:2016-07-15 09:58:49

标签: javascript angularjs

我有一个主页有一个标题的应用程序。但是,点击主页上的按钮,我想导航到另一个页面,该页面具有不同的标题,并且该页面内的内容呈现为ng-view,并且在更改网址时,ng-view内容将更改为同时标题也需要改变。请任何人给出一些想法。

2 个答案:

答案 0 :(得分:0)

将标题移动到ng-view中,但我宁愿使用ngRoute和嵌套的ui-view https://github.com/angular-ui/ui-router

答案 1 :(得分:0)

您可以使用状态路由器。

很遗憾,在ng路由器中,您无法在pageEg上拥有多个视图:将路由定义为:

.state('/',{

    header:{
        templateUrl: 'urlpathHeader',
        controller: headerController
    },
    content: {
         templateUrl: 'urlpathContent',
         controller: ContentController
    },


})
.state('other',{

    header:{
        templateUrl: 'otherurlpathHeader',
        controller: OtherheaderController
    },
    content: {
         templateUrl: 'urlpathContent',
         controller: ContentController
    },


})

在您的视图中(html)

<div ui-view="header">
<div ui-view="content">

为清晰起见,请在此处查找文档:

https://github.com/angular-ui/ui-router