我正在编写一个具有多个属性的组件,如果没有提供,我想要默认为一个值.
虽然我知道我可以像这样在组件控制器中测试这些属性的存在,
this.foo = angular.isUndefined(this.foo) ? 'Light Blue' : this.foo;
Run Code Online (Sandbox Code Playgroud)
我在想,如果有在提供缺省值的更优雅的方式binding本身
.component('myComponent', {
bindings: {
foo: '<?Light Blue'
},
Run Code Online (Sandbox Code Playgroud)
或类似的东西