AngularJS - JSON数据视图控制器 [英] AngularJS - json data from view to controller

查看:168
本文介绍了AngularJS - JSON数据视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从XSL转换让我的HTML模板+ JSON数据,它是动态的,它看起来像HTML code加上字符串化的JSON一些数据。现在的问题是:用什么方式我把HTML code JSON字符串,因此该控制器将捕获的HTML渲染之前这个JSON数据?当我把简单的像这样:

I get my html template + json data from xsl translator , it is dynamic , it looks like html code plus some data in stringified json. The question is: in what way i put the json string in html code , so that controller will catch this json data before html rendering? When i simple put it like this:

<div>{{ $scope.categories = [{},{},...]}}</div>
<div ng-repeat="category in categories" class="category">...</div>

它的作品不错,但带来了一些奇怪的错误:

it works good , but brings some strange error:

Error: 10 $digest() iterations reached. Aborting!

那么,什么是从视图数据传递给控制器​​的好办法吗?

So what is the good way to pass data from view to controller?

推荐答案

我张贴在这里整个独白:<一href=\"http://stackoverflow.com/questions/18097923/angularjs-getting-data-inserted-in-a-dom\">AngularJS - 获取插入到DOM数据

I posted entire monologue here: AngularJS - Getting data inserted in a dom

到现在我已经发现了两个方法,一个是模块方法和第二被传递从脚本类型=模板数据指令,然后从指令范围。

Till now i have found two ways, one is Module's value method and a second is passing a data from a script type="template" to directive and then from directive to scope.

我不知道他们是常规的或没有,但他们为我工作很好,他们都在我的眼睛Angulary够了......

I don't know if they are conventional or no , but they are working well for me and they are "Angulary" enough in my eyes...

这篇关于AngularJS - JSON数据视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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