我试图绑定角度js组件中的通用属性。我的组件包含文本框,我需要的是我想将html属性传递给组件模板。 即将HTML属性传递给角度js 1.5组件
<sample-component generic-attribute="ng-class='hello'"></sample-component>
这是我的主要html组件。我需要将ng-class传递给我的组件模板。
(function() {
angular.module('myApp').component('sampleComponent',{
bindings: {
genericAttribute:'@?'
},
controllerAs:'ctrl',
controller: 'sampleController',
template:'<input type="text" {{ctrl.genericAttribute}} >
});
})();
是否可以传递整个属性并将其绑定到模板中。
如果你想,你可以传递类中的类。为什么你还想传递属性是否有原因? – gyc
所以它会很普遍。那就是开发人员可以在同一个密钥上传递ng-class,id等。即 sample-component> –