select に対してラッパー ディレクティブを作成しようとしていて、select に「name」属性を割り当てようとしています
指令
<form name=myform>
<selectformfield label="Select Orders" id="id_1" name="orderselection"
selectedval="obj.order" options="Orders" />
</form>
ディレクティブを次のように定義しています
mainApp
.directive(
'selectformfield',
function() {
return {
restrict : 'E',
transclude : true,
scope : {
label : '@',
id : '@',
selectedval : '=',
options : '=',
name: '='
},
template : "<select class='form-control' ng-model='selectedval' name='{{name}}' ng-options='item as item.name for item in options' required><option value=''>-- select --</option></select>"
};
});
console.log($scope.myForm.orderselection) のようなコントローラーの myform を介して select の name 属性にアクセスしようとしていますが、未定義になります
ディレクティブで名前をハードコーディングすると、属性 console.log($scope.myForm.orderselection) にアクセスできます
ここで何かが欠けています。ポストコンパイルなどを行う必要がありますか?