Angular.js UI-Router模板未加载 [英] Angular.js UI-Router templates are not loading

查看:71
本文介绍了Angular.js UI-Router模板未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个简单的Angular网站.对于路由,我使用的是Angular-ui-router.当我单击主页时,关于模板不会加载,而当我单击联系时,模板会完美加载.有人可以帮我弄错的地方.这里是pl子的链接

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆