HTML的负荷后角引导 [英] Angular bootstrapping after load of html

查看:170
本文介绍了HTML的负荷后角引导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先初始化我的应用程序在body标签NG-应用=对myApp,这工作正常,因为这是第一次页面加载加载的所有angularized-HTML。

I first initialize my app with ng-app="myApp" in the body tag and this works fine for all angularized-html that is loaded on first page load.

后来我有一些code加载angularized-HTML到DOM。

Later on I have some code that loads angularized-html in to the DOM.

在角1.08我可以负荷运行后angular.bootstrap($ newLoadHTML,[对myApp])和它的工作;其中$ newLoadHTML是新加入的HTML抓住与jQuery。

In angular 1.08 I could just run angular.bootstrap($newLoadHTML, ["myApp"]) after the load and it would work; where $newLoadHTML is the newly added HTML grabbed with jQuery.

在角1.2这确实不再起作用:(

In angular 1.2 this does no longer work:(

错误:[NG:btstrpd]应用已与此元素'<自举href=\"http://errors.angularjs.org/1.2.0-rc.2/ng/btstrpd?p0=%3Cdiv%20ng-controller%3D%22AfterCtrl%22%3E\">http://errors.angularjs.org/1.2.0-rc.2/ng/btstrpd?p0=%3Cdiv%20ng-controller%3D%22AfterCtrl%22%3E

Error: [ng:btstrpd] App Already Bootstrapped with this Element '' http://errors.angularjs.org/1.2.0-rc.2/ng/btstrpd?p0=%3Cdiv%20ng-controller%3D%22AfterCtrl%22%3E

我得到这个错误,我理解,但我不知道如何解决它。

I am getting this error which I understand, but I don't know how to solve it.

我需要能够做的是负载angularized-HTML,然后进行角度意识到这一点。

What I need to be able to do is load angularized-html and then make angular aware of it.

下面是一个plunker来说明吧:<一href=\"http://plnkr.co/edit/AHMkqEO4T6LxJvjuiMeT?p=$p$pview\">http://plnkr.co/edit/AHMkqEO4T6LxJvjuiMeT?p=$p$pview

Here is a plunker to illustrate it: http://plnkr.co/edit/AHMkqEO4T6LxJvjuiMeT?p=preview

推荐答案

<一个href=\"http://stackoverflow.com/questions/15250644/angularjs-loading-a-controller-dynamically\">AngularJS:加载控制器动态

在这个问题的答案固定我的问题。因为我需要创建控制器后的内容物添加到DOM。此修复程序需要我,我已经宣布后,也注册控制器。如果有人在一个简单的解决方案pleace芯片。

The answer to this question fixed my problem. Since I need to create the controllers after the content was added to the DOM. This fix requires me too register controllers after I have declared it. If someone has an easier solution pleace chip in.

这篇关于HTML的负荷后角引导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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