Phil
Phil

Reputation: 50346

How to pass an object from ng-repeat to component using AngularDart?

I have a component called

<checkbox_component  ng-repeat="ccc in cmp.teachers1" 
label="{{ccc.name}}" objectValue="{{ccc}}"></checkbox_component>

Should I declare objectValue as a NgAttr? but that doesn't work I think it only works with strings.


Here I want to complain, I find it relatively difficult to communication between components. Lets say I have a component which is a page and then it has some components of mine on that page, its slightly hard to communication from the child components to the parent components and back again, either due to my lack of knowledge or some limitation.

Upvotes: 1

Views: 438

Answers (2)

Ozan
Ozan

Reputation: 4415

Either use the @NgTwoWay annotation or the NgModel Decorator:

<checkbox_component  ng-repeat="ccc in cmp.teachers1" ng-model="ccc"></checkbox_component>
@NgComponent(
  selector: 'checkbox_component[ng-model]',
  ...
)
class CheckboxComponent  {
  NgModel _ngModel;
  CheckboxComponent(this._ngModel);

  ...
}

Take a look at how NgModel is used at class InputCheckbox here.

Upvotes: 1

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657018

You are right. @NgAttr can only work with literal values but you can use @NgTwoWay

Upvotes: 1

Related Questions