我在我使用templateUrl获取模板的指令中为我的角度应用程序创建了一个指令。角度指令中模板的路径?
templateUrl: 'templates/searchbox-template.html',
这工作得很好我的本地服务器上,但是当我主持它的火力也给出了这样的警告repeatedly-
WARNING: Tried to load angular more than once
而且页面陷在一个循环,反复增加的index.html页。 如果您从我使用过指令的导航栏中转到公司或作业选项卡,则可以看到应用程序here。 我无法弄清楚我应该用什么路径来阻止它。这里是应用程序的结构 -
.
├── app
│ ├── 404.html
│ ├── favicon.ico
│ ├── images
│ ├── index.html
│ ├── robots.txt
│ ├── scripts
│ ├── styles
│ ├── templates
│ └── views
├── bower_components
│ ├── angular
│ ├── angular-mocks
│ ├── angular-route
│ ├── animate.css
│ ├── bootstrap
│ ├── jquery
│ └── jssocials
├── bower.json
├── dist
│ ├── 404.html
│ ├── favicon.ico
│ ├── fonts
│ ├── index.html
│ ├── robots.txt
│ ├── scripts
│ └── styles
├── firebase.json
.
├── app
│ ├── 404.html
│ ├── favicon.ico
│ ├── images
│ ├── index.html
│ ├── robots.txt
│ ├── scripts
│ │ ├── app.js
│ │ ├── controllers
│ │ ├── directives
│ │ └── services
│ ├── styles
│ │ └── main.css
│ ├── templates
│ │ └── searchbox-template.html
│ └── views
│ ├── about.html
│ ├── companiesall.html
│ ├── company.html
│ ├── contact.html
│ ├── jobsall.html
│ └── main.html
正如你可以看到我的模板在模板文件夹。请帮我解决一下这个。谢谢。
更新 - Accoring这个answer,该指令是无法找到的模板,因此一次又一次加载,因为这样做的index.html的 -
.otherwise({
redirectTo: '/'
});
我只需要找出正确的路径为模板。
这是firebase.json JSON文件的内容 -
{
"hosting": {
"public": "dist",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
这是否模板包含偶然的NG-应用程序的指令?如果您已经在主模板中获得了ng-app,然后尝试加载另一个在其中具有ng-app的应用程序,则可能会发生此消息。 – stevenelberger
不,ng-app只在index.html文件中。 – doctorsherlock
取决于你的服务器配置,但是如果'/ /'指的是你的根目录中的'index.html',那么我会想象正确的路径是'/ templates/searchbox-template.html'' – stevenelberger