0
我有一个指令,如下所示的自定义指令,我希望能够通过templateUrl在自定义指令angularjs传递字符串属性为templateUrl
<div ng-if="box.key === 'experiences'"
experiences-form
template-url="'experiences.php'" // template url I am trying to pass
item="item"
forms="forms"
form-name="{{box.key}}{{item._id}}"
onsave="updateMultipleUser(box.key, item._id, $data)"
cancel="formAction($formName, 'cancel')"
>
</div>
DDO的指令
{
restrict: 'A',
replace: true,
scope: {
onsave: '&',
cancel: '&',
formName: '@',
forms: '=',
item: '='
},
controller: controller,
templateUrl: function (tElement, tAttrs) {
return tAttrs.templateUrl; // returns 'experiences.php' how to get rid of the single quotes?
}
};
只需删除它们。 – zeroflagL
好吧,我得到了他们删除他们来说,这是行不通的,我第一次尝试,由于某种原因,我想如果没有把单引号,它会尝试和寻找一个$ scope.experiences.php工作 – ericsicons