angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.79k stars 27.48k forks source link

Angular component - separate bindings to inputs and outputs #15913

Open radek-anuszewski opened 7 years ago

radek-anuszewski commented 7 years ago

I'm submitting a ...

Current behavior:

Today, with 1.5 version and greaters, I can declare bindingsas:

bindings: {
  value: "<",
  name: "@",
  onChange: "&",
},

Expected / new behavior:

To be closer to Angular 2+, and to make code more intuitive with new trends about inputs and outputs, it can be separated to inputsand outputs:

inputs: {
  value: "<",
  name: "@",
},
outputs: {
  onChange: "&",
},

Angular version: 1.6.4

Browser: [all]

Anything else:

It may be even join internally by componentto bindings, so it won't be a breaking change I think, but for Angular's users it will make a difference with more separation and clarification. Thank you in advance for considering this feature!

gkalpak commented 7 years ago

This is still different than Angular, so I don't see much value. It might be interesting to support inputs/outputs as arrays, which is what Angular does.

E.g.

{
  ...
  inputs: ['value:<', 'name:@'],
  outputs: ['onChange:&']
}

...which is equivalent to Angular's...

{
  ...
  inputs: ['value', 'name'],
  outputs: ['onChange']
}

...and AngularJS'...

{
  ...
  bindings: {
    value: '<',
    name: '@',
    onChange: '&'
  }
}
Narretz commented 7 years ago

I agree with @gkalpak that this is not very useful, especially since it doesn't map 1:1 to Angular.

radek-anuszewski commented 7 years ago

@gkalpak solutions is also 100% ok for me.

gkalpak commented 7 years ago

I'll put it in the backlog. PRs are welcome (I guess)...