【发布时间】:2017-06-29 23:13:42
【问题描述】:
目前我正在处理一个非常广泛的表单,并在 HTML 上使用输入、文本区域、日期选择器等,这会使代码看起来非常难看,也很难阅读。 问题是我创建了返回正确 HTML 元素的自定义指令,例如:
在 HTML 中
<suggest-input data-ng-model="EDCtrl.headerStep.provider.identification"
placeholder="'Ej. 888888-8'"
label="'Identificador de emisor'">
</suggest-input>
指令:
var suggestInput = function ($compile, $http) {
return {
restrict: 'E',
require: 'ngModel',
templateUrl: templates + '/suggestInputTemplate.tpl.html',
replace: true,
scope: {
model: '=ngModel',
label: '=label',
title: '=title',
placeholder : '=placeholder'
},
};
};
模板
<div>
<label>{{ label }}</label>
<input class="form-control" data-ng-model="model" placeholder="{{ placeholder }}" call="functionName()"/>
</div>
我在自定义指令中使用角度引导指令时遇到问题,例如: 如何在自定义指令中使用这种配置调用“uib-typeahead”?
有什么想法吗?
【问题讨论】:
标签: javascript angularjs directive angular-bootstrap