TemplateUrl angularJS not working
TemplateUrl angularJS not working
我有这样的templateUrl问题我的目录
myapp
js
home.js
templates
profile.html
我在home.js 中尝试过
.state('app.profile', {
url : '/profile',
views : {
'appContent' : {
templateUrl: '/templates/profile.html',
controller: 'ProfileController'
}
}
})
在我的个人资料.html中,我有
<ion-view>
<ion-content padding="true">
<div>
<p>My content</p>
</div>
</ion-content>
</ion-view>
它不起作用,但当我尝试时
.state('app.profile', {
url : '/profile',
views : {
'appContent' : {
template: '<ion-view><ion-content padding="true"><div><p>My content</p></div></ion-content></ion-view>',
controller: 'ProfileController'
}
}
})
它工作正常。怎么了?我该怎么修?
您所需要做的就是在模板之前删除额外的/
.state('app.profile', {
url : '/profile',
views : {
'appContent' : {
templateUrl: 'templates/profile.html',
controller: 'ProfileController'
}
}})
您可以在脚本顶部导入模板,并将其用作"模板",而不是"templateUrl":
import profile from '/templates/profile.html';
...
.state('app.profile', {
url : '/profile',
views : {
'appContent' : {
template: profile ,
controller: 'ProfileController'
}
}
})
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working