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
-
Can you post your partial code?Davin Tryon– Davin Tryon2013-11-18 15:43:03 +00:00Commented Nov 18, 2013 at 15:43
-
Could you by any chance make use of $inject? docs.angularjs.org/api/AUTO.$injectorLauri Elias– Lauri Elias2013-11-18 15:56:31 +00:00Commented Nov 18, 2013 at 15:56
-
answer depends on what type of code you have...is it a new controller/directive etc? Or some DOM manipulation code...need more detailscharlietfl– charlietfl2013-11-18 16:12:39 +00:00Commented Nov 18, 2013 at 16:12
Add a comment
|
1 Answer
This seems pretty similar to this question AngularJS: How to run additional code after AngularJS has rendered a template?
Accordng to this, your best bet might be to use $evalAsync()
http://docs.angularjs.org/api/ng.$rootScope.Scope#$evalAsync
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.