Angular.js UI-Router 模板未加载 [英] Angular.js UI-Router templates are not loading
问题描述
我正在制作一个简单的 Angular 网站.对于路由,我使用的是 Angular-ui-router.当我点击主页时,关于模板没有加载,而当我点击联系时,模板加载完美.有人可以帮助我犯错的地方.这是plunker的链接
I'm making a simple Angular Website. For Routing I'm using Angular-ui-router. When I click on Home, About the templates are not loading whereas when I click on Contact the template loads perfectly. Can someone please help me where I made a mistake.Here is the link for plunker
> https://plnkr.co/edit/8LlDl08JVbQKiD5eWEah?p=preview
推荐答案
您用于联系主页和几乎总是相同的模块 'homeModel'
you are using for contact home and about always same module 'homeModel'
angular.module('homeModel', [])
联系人是最后一个并覆盖它
the contact ist the last one and overwrites it
<script src="home.component.js"></script>
<script src="about.component.js"></script>
<script src="contact.component.js"></script>
所以为每个组件使用唯一的模块
so use unique module for every component
还要确保将其添加到脚本中,例如
also make sure you add it in your script for example
angular.module('myVin', ['ui.router', 'homeModel', 'contactModel', 'aboutModel'])
也删除反斜杠以获得 about.html
also remove backslash to get about.html
templateUrl: '/about.html',
这篇关于Angular.js UI-Router 模板未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!