im trying to display an object with 10-20 attributes.
some of the values of these attributes are also similarly big objects or arrays of such objects.
i would like to omit prefixing each field name with the sub-object's name.
similarly as knockoutjs does in their example on the homepage:
<p data-bind="with: chosenTicket">
xxx <b data-bind="text: name"></b>
…
pascal had a similar construct which was also called "with"
so how can i achieve something like this in angular:
$scope.obj = {
f1: 123123
f2: "asdasd"
…
f13: {
sub1: true
sub2: 555
…
sub20: null
}
f18: [ {...}, {…}, ... ]
}
<p with="obj">
<h3>{{f1}}</h3>
<p>{{f2}}<p>
...
<div with="f13">
Done: {{sub1}}
Size: {{sub2}}
…
<span ng-show="sub20">OK</span>
</div>
...
</p>
instead of the current
<p>
<h3>{{obj.f1}}</h3>
<p>{{obj.f2}}<p>
...
<div with="obj.f13">
Done: {{obj.f13.sub1}}
Size: {{obj.f13.sub2}}
…
<span ng-show="obj.f13.sub20">OK</span>
</div>
...
</p>
i was trying to hack it like this:
<script type="text/ng-template" id="/embedded.html">
<div>
Done: {{sub1}}
Size: {{sub2}}
…
<span ng-show="sub20">OK</span>
</div>
</script>
<div ng-inculde src="'/embedded.html'" scope="extend($new, obj.f13)"></div>
but it didnt do anything.
didn't throw any error either which made me feel good about it actually :)
i have the impression that i really read the full docs…
would these sections make me understand whats going on?
http://docs-next.angularjs.org/api/angular.module.ng.$rootScope.Scope
http://docs-next.angularjs.org/api/angular.module.ng.$compileProvider.directive
is it silly for some reason what i want?
pls, help.
--
tom
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
Would you like to have an AngularJS t-shirt ?
Fill in this form
https://docs.google.com/spreadsheet/viewform?formkey=dGlWVFNocm9hWFF0Z3htVUZkNTFqOVE6MQ
and we will send you some...
V.
Interesting approach. But (of course) it breaks the 2way databinding,
since the attributes will be copied to the new scope. Is there any
chance to achieve the same effect without making new copies of the
data?
Or try to keep the two copies in sync with a $watch for every
attribute? It sounds too hackish.
Andras
> Hi TamasInteresting approach. But (of course) it breaks the 2way databinding,
> You can get this effect by extending the scope inside a controller. For
> each new controller a new scope is created that exists only where that
> controller exists so you are free to hack it to bits as long as you are sure
> that is what you want to do.
> See this fiddle: http://jsfiddle.net/86kuc/
> Pete
since the attributes will be copied to the new scope. Is there any
chance to achieve the same effect without making new copies of the
data?
Or try to keep the two copies in sync with a $watch for every
attribute? It sounds too hackish.