Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 多个视图无法渲染_Angularjs_Angular Ui Router_Ionic_Ionic View_Angularjs View - Fatal编程技术网

Angularjs 多个视图无法渲染

Angularjs 多个视图无法渲染,angularjs,angular-ui-router,ionic,ionic-view,angularjs-view,Angularjs,Angular Ui Router,Ionic,Ionic View,Angularjs View,我如何拥有多个ionic视图我尝试了很多方法让它工作,但都失败了 以下是我的Angular Ionic应用程序的相关部分: 看法 路由 .config( 函数($stateProvider,$urlRouterProvider){ $urlRouterProvider。否则('/'); $stateProvider .state('错误'{ 观点:{ 错误视图:{ templateUrl:'main/templates/errors.html' } } }) .州(“家”{ url:“/”,

我如何拥有多个ionic视图我尝试了很多方法让它工作,但都失败了

以下是我的Angular Ionic应用程序的相关部分:

看法

路由
.config(
函数($stateProvider,$urlRouterProvider){
$urlRouterProvider。否则('/');
$stateProvider
.state('错误'{
观点:{
错误视图:{
templateUrl:'main/templates/errors.html'
}
}
})
.州(“家”{
url:“/”,
templateUrl:'main/templates/home.html',
})
}
main/templates/errors.html
Errors ahoy
main/templates/home.html
Tadaima

但是,渲染输出只是:


塔代马

你已经看过这部电影了吗

它使用了一种“嵌套视图”方法,您可能可以在项目中采用这种方法。 例如:

  .state('home', {
      url: '/',
      // loaded into ui-view of parent's template
      views:{
        'homePage': {
          templateUrl: 'main/templates/home.html',
          controller: 'HomeController'
        },
        'errorPage': {
          templateUrl: 'main/templates/errors.html',
          controller: 'ErrorController'
        }
      },
      onEnter: function(){
        console.log("enter home");
      }
  })

“多视图”是什么意思?多个视图都同时可见?是的,这就是我的意思。可能状态是错误的,我应该使用
ng include
或甚至是自定义
指令来代替…是的,我知道子视图方法,但这需要对所有内容进行命名空间,因为所有内容都会发出错误状态。
  .state('home', {
      url: '/',
      // loaded into ui-view of parent's template
      views:{
        'homePage': {
          templateUrl: 'main/templates/home.html',
          controller: 'HomeController'
        },
        'errorPage': {
          templateUrl: 'main/templates/errors.html',
          controller: 'ErrorController'
        }
      },
      onEnter: function(){
        console.log("enter home");
      }
  })