Angular 1.5 component defaults

I am writing a component that has several properties that I want to use by default if this is not specified.

So far I know that I can check for the presence of these properties in the component controller, for example,

this.foo = angular.isUndefined(this.foo) ? 'Light Blue' : this.foo; 

I was wondering if there was a more elegant way of providing a default value in the binding itself

 .component('myComponent', { bindings: { foo: '<?Light Blue' }, 

or something like that

+5
source share

Source: https://habr.com/ru/post/1260199/


All Articles