簡體   English   中英

如何正確更改路由控制器?

[英]How correct change route controller?

我有簡單的表格頁面(帶有控制器)和類似ng-controller="messageGridCtrl" ng-init="init()"並使用其他控制器創建頁面。

當我單擊更改路由並調用init方法,但請求無效時,“創建頁面”具有諸如<a href="#/messageTemplates">Back to list</a>類的反向鏈接,但請求不起作用(不接收服務器)。 如果我只是重新加載(通過f5),一切正常。

我是angularjs的新手。

angular-route-segment文檔中

$routeSegmentProvider.

when('/section1',          's1.home').
when('/section1/prefs',    's1.prefs').
when('/section1/:id',      's1.itemInfo.overview').
when('/section1/:id/edit', 's1.itemInfo.edit').
when('/section2',          's2').

segment('s1', {
    templateUrl: 'templates/section1.html',
    controller: MainCtrl}).

within().

    segment('home', {
        templateUrl: 'templates/section1/home.html'}).

    segment('itemInfo', {
        templateUrl: 'templates/section1/item.html',
        controller: Section1ItemCtrl,
        dependencies: ['id']}).

    within().

        segment('overview', {
            templateUrl: 'templates/section1/item/overview.html'}).

        segment('edit', {
             templateUrl: 'templates/section1/item/edit.html'}).

        up().

    segment('prefs', {
        templateUrl: 'templates/section1/prefs.html'}).

    up().

segment('s2', {
    templateUrl: 'templates/section2.html',
    controller: MainCtrl});

可能對你有幫助

http://scotch.io/tutorials/javascript/angularjs-multi-step-form-using-ui-router

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM