- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
这是我的项目的一个小节:
<div class="col-md-3 col-sm-4">
<checked-input
pholder="{{'publications-customDomain' | translate}}"
class="add-publisher-input"
ng-model="customDomain.text"
icon="glyphicon-globe"
type="publicationCustomDomain"
page="publications">
</checked-input>
</div>
<div class="col-md-3 col-sm-4">
<button ng-if="isBtnClassDisabled===false" class="add-domain btn btn-primary" ng-click="vm.addUserPublisher(currentTab)">
<span class="glyphicon glyphicon-plus"></span>{{'publications-addDomain' | translate}}
</button>
</div>
它的工作方式是,checked-input
验证输入的任何内容以确保它是一个 URL,一旦验证通过,isBtnClassDisabled
变为 false,以便出现第二个 div 中的按钮,您可以单击它。这调用函数 vm.addUserPublisher
, 但是,当我尝试记录 this.scope.customDomain
(ng-model
的 checked-input
)从 Controller ,控制台返回 undefined
.谁能解释为什么?谢谢。
编辑 1 - 我的 Controller 如下所示:
class mainPublicationsCtrl {
private scope: any;
private timeout: any;
private modal: any;
private route: any;
private http: any;
private mainScope: any;
private selSiteServ: any;
static $inject = ['$scope'];
constructor($scope, $timeout, $http, $modal, $route, selSiteServ) {
$scope.vm = this;
$scope.isBtnClassDisabled = true;
$scope.selectedItem = 0;
$scope.countOfTabs = 1;
$scope.customDomain = {
text: ""
}
this.scope = $scope;
...
addUserPublisher(tab: any) {
console.log(this.scope.customDomain.text);
}
...
}
编辑 2 - <checked-input>
指令定义如下:
模板:
<div>
<div class="input-info-wrap">
<div class="input-inform state-normal"></div>
</div>
<div class="input-group">
<span ng-if="icon != '' && !isFaIcon"
class="input-group-addon glyphicon {{icon}} icon-inline btn-item">
</span>
<span ng-if="icon != '' && isFaIcon"
class="input-group-addon fa {{icon}} fa-input-label-size icon-inline btn-item">
</span>
<input type="text"
class="form-control btn-item form-tab-input"
placeholder="{{pholder}}"
ng-model="model"
maxlength="20">
<span class="input-group-addon glyphicon glyphicon-asterisk input-state"></span>
</div>
</div>
Java脚本:
class checkedInput implements ng.IDirective {
public link: (scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => void;
public templateUrl = 'partials/directives/checked-input.html';
public scope = {
model: "=",
icon: "@",
pholder: "@",
type: "@",
page: "@",
num: "@",
gstab: "=",
gsrow: "=",
tab: "=",
isFaIcon: "="
};
}
最佳答案
尝试为 checked-input
指令使用模板。在指令的模板中定义 ng-model
,而不是在 HTML 中显式定义。
关于javascript - Angular javascript ng模型不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31320396/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!