Javascript 如何在AngularJS中使用templateUrl?
在我的home.js文件中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
.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" }
}
})