Javascript无法与从ui-router加载的动态视图一起运行 [英] Javascript can't run with dynamic views loaded from ui-router

查看:49
本文介绍了Javascript无法与从ui-router加载的动态视图一起运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用ui-router将模板加载到ui-view中时遇到问题. javascript已加载,但未在加载的视图上运行. 全文是: 我有一个带有完整js,css ...文件的HTML模板.一切都可以完美地在HTML中运行.然后,我使用UI-Router添加AngularJS,以使页面随视图动态变化. 我的代码如下:

I have a problem when I try to load template into ui-view using ui-router. The javascript is loaded but not running on loaded views. The full story is that: I have a template in HTML with full js, css... files. Everything runs perfectly in HTML. Then I add AngularJS with UI-Router to make the page dynamic with view. My code looks like:

<head>
<script src="angular.js"></script>
<script src="angular-ui-router.min.js"></script>
</head>
<body>
 <h1>This is the content of dynamic view</h1>
<div ui-view></div>

<script src="jquery.min.js"></script>
<script src="jqueryui.min.js"></script>
... 
<script src="isotype.min.js"></script>
</body>

当我从ui路由器加载视图时,布局是正确的.但没有javascript效果正在运行. 我该如何解决?我想在index.html中加载js文件列表,以便当它更改ui视图时,我不必再次加载它们.

When I load the view from ui-router, the layout is correct. But no javascript effects are running. How can I fix that? I want to load a list of js files in the index.html so that when it change the ui-view, i don't have to load them again.

推荐答案

我已经找到解决此问题的方法.我在html模板中配置每个元素的文件custom.js将放入HTML模板文件中. 索引文件加载HTML模板时,还将同时加载custom.js文件.

I have found the way to fix this problem. The file custom.js which I config every elements in the html template, will be put in the HTML template file. When the index file loads the HTML template, it will load the custom.js file also.

这篇关于Javascript无法与从ui-router加载的动态视图一起运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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