3

It was possible to require NgModelController in AngularJS Components. Something like require:

// AngularJS component's definition
{
  // ...
  ngModel: '^'
  // ...
}

Is it possible to require NgModelController (from AngularJS) instance in Angular Component (like it is possible in AngularJS).

I have a hybrid app. I want to use Angular Component in AngularJS component's template like:

<ng-form>
  <a2-cmp ng-model="x"></a2-cmp>
</ng-form>

I had some AngularJS component which was using like:

<ng-form>
  <a1-cmp ng-model="x"></a1-cmp>
</ng-form>

And inside of a1-cmp component methods like $setViewValue were used. So now I rewrote that component to Angular, but I need to support that mechanism of syncing between inner and outer components. It was not problem because both (inner and outer) components were AngularJS. Now inner is Angular, but outer is AngularJS component.

Is it somehow possible? I need this to influence AngularJS NgForm instance state (pristine/validity) from Angular component's code.

There are different workarounds to do that (the most simple is to pass ngForm instance to Angular component and call methods)

Sharikov Vladislav
  • 7,049
  • 9
  • 50
  • 87
  • is this directive created by you? a1-cmp and a2-cmp – Rakesh Burbure Feb 26 '18 at 11:12
  • Yes both of them are created by me. I just want to minify efforts to rewrite AngularJS component to Angular component. – Sharikov Vladislav Feb 26 '18 at 12:41
  • @SharikovVladislav , Did you solve this issue? – arun Feb 11 '19 at 10:20
  • 1
    @arun If I remember correcly, we added wrapper without ngModel, but with simple inputs/outputs. Also if we need any validation stuff, we passed it manually. Not really good solution. And also now we try to avoid hybrid stuff and rewrite whole "views". So now we try to avoid this problem – Sharikov Vladislav Feb 14 '19 at 11:09

0 Answers0