问题描述
我从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?
推荐答案
我张贴在这里整个独白: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数据视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!