我正在尝试在使用 angularJs 指令中添加动态添加属性我想在表单中动态添加 html 标记
我的观点 :
<div ng-show="edit_tasks">
<edittask-form><edittask-form>
</div>
我的表单 HTML
{
<div>
<form ng-submit="submitFrom()" csrf-tokenized>
Task Name<input type="text" placeholder="Name" ng-model="newtask.name" required />
Task Description<input type="text" placeholder="Description" ng-model="newtask.description" required />
Start Date <input type="text" placeholder="Start date" ng-model="newtask.start_date" required />
Start Date <input type="text" placeholder="End date" ng-model="newtask.end_date" required />
<input type="submit" value="submit" />
</form>
</div>
}
我的指令
module.directive("edittaskForm", function() {
return {
restrict: "E",
templateUrl: "<%=asset_path 'tasks/task_form.html' %>",
controller: tasksCtrl,
replace: false,
link: function(scope, elt, attrs, controller) {
scope.form = elt.find("form");
console.log(scope.form);
scope.taskEdit = function(task) {
scope.task = task;
scope.show_tasks = false;
scope.edit_tasks = true;
scope.newtask = task;
};
}
}
});
如何<input type="text" name="xyz" />
在表单中添加
提前考虑