2016-06-26 8 views
0

Ich arbeite mit AngularJs, und ich habe derzeit ein Problem mit UI-Router. Die Ansicht 'patientBoard' im Status 'home.logged.board.patientDashboard' ersetzt nicht die im übergeordneten Status. Ich weiß nicht, warum es das tut, ich habe keine Fehler auf der Konsole und alle TemplateUrl sind korrekt. Ich habe auch versucht, den Ansichtsnamen 'patientBoard' zu 'patientBoard @' zu ersetzen, aber nohting ... Ich würde die ganze Hilfe schätzen, die anyone mir geben kann.Übergeordnete Ansicht wird nicht ersetzt

Dank

index.html

<!DOCTYPE html> 
<html lang="en" ng-app="neat"> 
    <head> 
     <meta charset="UTF-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <title>NEAT</title> 
     <base href="/"> 
     <link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.6/css/bootstrap.min.css"> 
     <link rel="stylesheet" type="text/css" href="../css/style.css"> 
     <script src="webjars/jquery/1.12.4/jquery.min.js"></script> 
     <script src="webjars/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
     <script src="webjars/angularjs/1.5.7/angular.min.js"></script> 
     <script src="webjars/angular-ui-router/0.2.18/angular-ui-router.min.js"></script> 
     <script src="../js/utils/utils.js"></script> 
     <script src="../js/neat.js"></script> 
    </head> 
    <body ng-controller="LanguageController"> 
     <div ng-controller="AuthenticationController"> 
      <header> 
       <div ui-view="navigationBar"></div> 
      </header> 
      <div ui-view></div> 
     </div> 
    </body> 
</html> 

board.html

<div class="container-fluid board"> 
    <div class="row"> 
     <div ui-view="patientBoard" class="col-sm-8"></div> 
     <div ui-view="messageBoard" class="col-sm-4"></div> 
    </div> 
</div> 

neat.js

angular.module('neat', ['ui.router', 'ngStomp', 'pascalprecht.translate']) 
    .config(function ($stateProvider, $urlRouterProvider) { 
     $stateProvider 
      .state('home', { 
       url: '/', 
       views: { 
        '': { 
         templateUrl: '/views/login/login.html' 
        }, 
        'navigationBar': { 
         templateUrl: '/views/navbar/navigationBar.html' 
        } 
       } 
      }) 
      .state('home.logged', { 
       abstract: 'true', 
       views: { 
        '@': { 
         templateUrl: '/views/board/board.html' 
        } 
       } 
      }) 
      .state('home.logged.board', { 
       resolve: { 
        homeHref: function(RequestService) { 
         return RequestService.getHome() 
          .then(function(response){ 
           return response.data; 
          }); 
        } 
       }, 
       views: { 
        'patientBoard' : { 
         templateUrl: '/views/board/patient/patientTable.html', 
         controller: 'PatientTableController' 
        }, 
        'messageBoard' : { 
         templateUrl: '/views/board/message/messageBoard.html', 
         controller: 'MessageBoardController' 
        } 
       } 
      }) 
      .state('home.logged.board.patientDashboard', { 
       params: { 
        patientHref: null 
       }, 
       resolve: { 
        patientInfo: function($stateParams, RequestService) { 
         return RequestService.get($stateParams.patientHref) 
          .then(function(response) { 
           return response.data; 
          }) 
        } 
       }, 
       views: { 
        'patientBoard' : { 
         templateUrl: '/views/board/patient/patientDashboard.html', 
         controller: 'PatientDashboardController' 
        } 
       } 
      }) 
      .state('home.logged.board.patientDashboard.patientInfo', { 
       views: { 
        '': { 
         templateUrl: '/views/board/patient/dashboard/patientInfo.html' 
        } 
       }, 
       controller: 'PatientInfoController' 
      }) 
      .state('home.logged.board.patientDashboard.patientAnalysis', { 
       views: { 
        '': { 
         templateUrl: '/views/board/patient/dashboard/patientAnalysis.html' 
        } 
       }, 
       controller: 'PatientAnalysisController' 
      }) 
      .state('home.logged.board.patientDashboard.patientHistory', { 
       views: { 
        '': { 
         templateUrl: '/views/board/patient/dashboard/patientHistory.html' 
        } 
       }, 
       controller: 'PatientHistoryController' 
      }); 

     $urlRouterProvider.otherwise('/'); 

    }); 

Antwort

1

Seit home.logged.board.patientDashboard ein Kind von home.logged.board, Der Status (patientDashboard) sucht in home.logged.board nach einer ui-view mit dem Namen "patientBoard".

Machen Sie patientDashboard Kind von home.logged (z. B. home.logged.patientDashboard) und sollte gut funktionieren.

.state('home.logged.patientDashboard', { params: { patientHref: null }, resolve: { patientInfo: function($stateParams, RequestService) { return RequestService.get($stateParams.patientHref) .then(function(response) { return response.data; }) } }, views: { 'patientBoard' : { templateUrl: '/views/board/patient/patientDashboard.html', controller: 'PatientDashboardController' } } })

Für mehr Information Check ui-Router-Dokumentationen zu: Nested states and views

+0

Es funktioniert jetzt! Vielen Dank! – gqmartins

Verwandte Themen