我正在创建一个指令,我想在其中比较存储在模型中的值(比如“名称”作为模型,它的值是“Angular”)存储在变量中。
我尝试了类似下面的东西,
var nameValue=name;
但它(nameValue)没有值“Angular”
Example:
app.directive('kmRadio', function() {
return{
restrict:'E',
compile: function(element,attrs) {
var model=ngModelName;
console.info(attrs.kmModel);
console.info("{{'+attrs.kmModel+'}}");
if(attrs.kmTitle==model) {
previewString="<input type="+"radio"+" checked>";
}
else {
previewString="<input type="+"radio"+">";
}
var htmlText=''+previewString+''+
element.replaceWith(htmlText);
}
}
})
谁能告诉我如何检索存储在模型(ng-model)中的值