【发布时间】:2018-06-16 20:44:07
【问题描述】:
所以我有这个自定义指令:
function numberPickerDirective() {
return {
template: template,
replace: 'true',
restrict: "E",
scope: {
id: "@",
name: "@",
model: "=",
value: "@",
min: "@"
},
}
}
我的模板如下所示:
<div class="number-picker">
<input id="{{id}}" name="{{name}}" ng-model="{{model}}"
ng-value="{{value}}" value="{{value}}" min="{{min}}" required
type="number" />
<div class="number__controls">
<button class="number__control-btn up-icon">
<svg viewBox="0 2 10 5" width="10" height="5" fill-rule="evenodd">
<path d="M10 5L5 0 0 5z"></path>
</svg>
</button>
<button class="number__control-btn down-icon">
<svg viewBox="0 2 10 5" width="10" height="5" fill-rule="evenodd">
<path d="M10 0L5 5 0 0z"></path>
</svg>
</button>
</div>
</div>
在我看来,我正在应用该指令:
<number-picker
id="inteval"
name="SizeSec"
ng-model="m.SizeSec"
value="30"
min="1"
required
type="number"
/>
问题是我的所有作用域变量都被应用于顶级 div,而我希望它们被应用于输入标签。谁能解释为什么会发生这种情况以及如何解决?
【问题讨论】:
-
我没听懂您的问题,请您改写一下好吗?
-
当我检查我的元素时,它最终呈现为:而不是由于某种原因,所有参数都被应用于错误的元素。
标签: javascript html angularjs angularjs-directive