如何加载脚本时angular.js部分加载 [英] how to load script when partial loading in angular.js

查看:167
本文介绍了如何加载脚本时angular.js部分加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用angular.js我的项目,并在局部或视图中添加脚本,但它不工作。我想包括脚本,单只偏,所以我不希望添加索引页面上的脚本。
有没有什么办法,以包括部分或视图angular.js一个脚本

I am using angular.js for my project and adding script in a partial or view but it is not working. I want to include script for single partial only so i don't want to add that script on the index page. Is there any way to include single script for a partial or view in angular.js

推荐答案

这似乎与此类似问题 AngularJS pretty:如何运行AngularJS后附加code已经呈现模板?

Accordng这个,你最好的选择可能是使用$ evalAsync()

Accordng to this, your best bet might be to use $evalAsync()

http://docs.angularjs.org/api/ng 。$ rootScope.Scope #$ evalAsync

http://docs.angularjs.org/api/ng.$rootScope.Scope#$evalAsync

虽然那种取决于你正在试图运行code是(张贴请?)。我的建议是尝试angularize无论你想在模板加载后这样做,你可以在你的控制器包含它。如果不行,再寻找其他解决方案。

Although that kind of depends on what the code you're trying to run is (post it pls?). My advice is try to "angularize" whatever you're trying to do after the template has loaded so that you can include it in your controller. If that doesn't work, then look for other solutions.

这篇关于如何加载脚本时angular.js部分加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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