angularjs - Angular - same view different binding contexts -
still trying make transition angular newb-type question please bear me -
in durandal/knockout can use compose binding show view under context of object ie. -
<div data-bind="with: firstperson"> <!-- ko compose: 'views/person' --><!-- /ko --> </div> <div data-bind="with: secondperson"> <!-- ko compose: 'views/person' --><!-- /ko --> </div> to show same view bound 2 separate knockout objects (observables)
but in angular have not found correct way bind within element context. how can display multiple html files various context(s?)?
i don't think ng-repeat because not array of objects, 2 separate properties on same object ie -
- parentobject
- firstperson
- secondperson
edit
obviously durandal , knockout can use
<span data-bind="text: fullname"></span> inside of person view without having define parent part of, how can achieved in angular?
you can use ng-include achieve that.
<ng-include ng-init="person=firstperson" ng-model="person" src="'/views/person.html'"/> <ng-include ng-init="person=secondperson" ng-model="person" src="'/views/person.html'"/> person.html maybe like
<div class="modal-body"> {{person.firstname}}, {{person.lastname}} </div> so can use same model person refer different data model (firstperson or secondperson)
Comments
Post a Comment