[英]How can i force angular to re-run its bindings, manually?
I am trying to integrate angular into an older existing web-app.我正在尝试将 angular 集成到旧的现有网络应用程序中。 I have a few places where large portions of the page are re-rendered from rails partials via ajax requests.我有几个地方通过ajax请求从rails部分重新呈现页面的大部分。
Once a portion of the page is re-rendered in this way, any existing angular bindings (eg: ng-click) are lost and buttons no longer work.一旦页面的一部分以这种方式重新呈现,任何现有的角度绑定(例如:ng-click)都会丢失,按钮不再起作用。 Is there any way to manually tell angular to re-check for binding attributes?有没有办法手动告诉 angular 重新检查绑定属性?
If you are loading some HTML and need angular to process it you'll need to run $compile on the HTML code for angular to parse for directives and you'll need to attach a scope to the returned link function.如果您正在加载一些 HTML 并需要 angular 来处理它,您需要在 HTML 代码上运行 $compile 以便 angular 解析指令,并且您需要将范围附加到返回的链接函数。 Show some code.显示一些代码。 If you are simply getting new data you can use $http which will automatically call $digest for you or else you can call $digest from some other callback to notify angular it needs to update the display.如果你只是简单地获取新数据,你可以使用 $http ,它会自动为你调用 $digest 或者你可以从其他回调中调用 $digest 来通知 angular 它需要更新显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.