admin管理员组文章数量:1313925
I want to use angular in an app except that angular is not loaded by default with the app. When a particular button is clicked, a new div is created and I want to use angular on that div.
I'm loading angular using yepnode as shown in the code below:
yepnope({
test:window.angular,nope: ['/filesystem/content/js/angular.js'],
plete: function(){ console.log('plete');}
});
Given that I've loaded angular and I have access to the div as $div, my next action will be
1. Create some html and use it as the innerHTML of $div
2. Create a controller (from another file eg /filesystem/controllers/abc.js
3. bind $div to controller and scope.
Not really sure how to proceed since in all my examples, I started with a page with angular loaded at started together with putting the ng-app tag on the html.
After loading angularjs, what are the next steps?
Thank you.
I want to use angular in an app except that angular is not loaded by default with the app. When a particular button is clicked, a new div is created and I want to use angular on that div.
I'm loading angular using yepnode as shown in the code below:
yepnope({
test:window.angular,nope: ['/filesystem/content/js/angular.js'],
plete: function(){ console.log('plete');}
});
Given that I've loaded angular and I have access to the div as $div, my next action will be
1. Create some html and use it as the innerHTML of $div
2. Create a controller (from another file eg /filesystem/controllers/abc.js
3. bind $div to controller and scope.
Not really sure how to proceed since in all my examples, I started with a page with angular loaded at started together with putting the ng-app tag on the html.
After loading angularjs, what are the next steps?
Thank you.
Share Improve this question asked Sep 10, 2012 at 21:07 ritcoderritcoder 3,29410 gold badges45 silver badges63 bronze badges 2- 1 docs.angularjs/guide/bootstrap shows you how to do manual bootstrap. – Tosh Commented Sep 10, 2012 at 21:38
- @toshshimayama: Exactly what I needed. Was able to bootstrap $div. Now looking at the controller. Can you post your ment as an answer so I accept it? Thanks. – ritcoder Commented Sep 11, 2012 at 6:45
1 Answer
Reset to default 7Angularjs guide page would help you.
http://docs.angularjs/guide/bootstrap
There is a description how to do the manual bootstrapping.
本文标签: javascriptLoading angularjs dynamically and generating controllers and scopeStack Overflow
版权声明:本文标题:javascript - Loading angularjs dynamically and generating controllers and scope - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741960738a2407261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论