Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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
Javascript 如何在AngularJS中使用templateUrl?_Javascript_Html_Templates_State_Angularjs Routing - Fatal编程技术网

Javascript 如何在AngularJS中使用templateUrl?

Javascript 如何在AngularJS中使用templateUrl?,javascript,html,templates,state,angularjs-routing,Javascript,Html,Templates,State,Angularjs Routing,在我的home.js文件中 .state('app.profile', { url : '/profile', views : { 'appContent' : { templateUrl: '../templates/profile.html', controller: 'HomeController' } } }) 在我的profile.html文件中 <ion-view titl

在我的home.js文件中

.state('app.profile', {
    url : '/profile',
    views : {
        'appContent' : {
            templateUrl: '../templates/profile.html',
            controller: 'HomeController'
        }
    }
})
在我的profile.html文件中

<ion-view title="Profile">
  <ion-content>
    <!--somethings here-->
  </ion-content>
</ion-view>

但我不能让它工作。请帮我修正这个错误

如果我理解正确,您必须这样做:

.state('index', {
    url : '/route1',
    templateUrl: '../templates/profile.html',
    controller: 'Controller'
})
如果要使用多个视图,请执行以下操作:

.state('index', {
    url: "/route1",
    views: {
      "viewA": { template: "index.viewA" },
      "viewB": { template: "index.viewB" }
    }
}) 

不,不,我的意思是:我在index.html文件中有这段代码,但我想把它们分成两个文件。我将的main复制到profile.html并更改此状态的templateUrl,但它不起作用。可能是,我不知道如何使用templateUrl:(这个老问题似乎无法解释问题是什么,所以我投票决定结束。如果可以,请编辑。
.state('index', {
    url: "/route1",
    views: {
      "viewA": { template: "index.viewA" },
      "viewB": { template: "index.viewB" }
    }
})