2014-10-05 51 views
0

我在一個控制器和三個ui視圖模板中使用了一個SinglePage-應用程序。 這裏的HTML:在ui視圖角度中使用公式

<div class="ng-scope" ng-controller="gameController">  
    <div ui-view="viewUser"></div> 
    <div ui-view="viewTeam"></div> 
    <div ui-view="viewGame"></div> 
</div> 

這裏的配置:

function($stateProvider, $urlRouterProvider){ 

    $urlRouterProvider.otherwise(""); 

    $stateProvider 
    .state('index', { 
      url: "", 
      controller: 'gameController', 
      views: { 
       "viewUser": { templateUrl: "templates/user-template.html" }, 
       "viewTeam": { templateUrl: "templates/team-template.html" }, 
       "viewGame": { templateUrl: "templates/game-template.html" } 
      } 
    }); 
} 

每個視圖都包含了NG-提交事件一個公式推,當我要提交,$ scope.formName是不確定的。如何在ui-view中使用「$ scope.teamName。$ valid」? 很高興回覆。

+0

什麼是表現公式? – 2014-10-08 20:47:21

+0

一個<表格名稱= 「用戶窗體」> ... HTML元素 其內側

...
2014-10-08 21:03:12

回答

0

如果我檢查gameController $ scope.on('$ viewContentLoaded',..並查看event.targetScope爲userForm或teamForm或gameForm我發現objectHTMLFormElement但當我嘗試添加新的用戶比$ scope.userForm是在功能$ scope.addUser()未定義{...}女巫中gameController定義。

$scope.$on('$viewContentLoaded', 
    function(event, viewConfig){ 
     console.log('#c : ---------------------------- '); 
     for(var e in event.targetScope){ 
      if(e.match(/^(userForm|teamForm|gameForm)$/)){ 
      console.log('#E : '+e) 
      } 
     } 
    } 
);