次の方法でコンポーネントを実装しました
angular.module('moduleName')
.component('myComponent', {
templateUrl: 'templatePath1.tpl.html',
controller: myController,
controllerAs: 'vm',
bindings: {
b1: '&',
b2: '&'
}
});
私はそれを<my-component b1="someThing1" b2="someThing2"></my-component>
myController
今、私は、にある別のテンプレートで同じものを使用したいと考えていますtemplatePath2.tpl.html
。
1 つの方法は、別のコンポーネントを作成することですmyComponent2
。
angular.module('moduleName')
.component('myComponent2', {
templateUrl: 'templatePath2.tpl.html',
controller: myController,
controllerAs: 'vm',
bindings: {
b1: '&',
b2: '&'
}
});
以前のコンポーネントを使用して、attr に基づいて templateUrl を選択する方法はありますか? はいの場合、どのようにそれを行うべきですか?