【发布时间】:2014-09-04 22:43:03
【问题描述】:
我有点卡在这里。我有一个应用程序,它使用带有来自服务器的值的几个文本框的引导模式。当我第一次打开模式并从文本框 ng-change 事件中删除项目时。清除所有字段后,我关闭了模式。当我再次打开模式时,它会填充新值,但是当我从文本框中删除项目时,不会触发 ng-change 事件。
但是在这里我发现了一件更奇怪的事情,上面提到的问题只有当我们在文本框中有一项时才会出现。
这是我的html代码:
<tr>
<td>
<input only-numeric class="floatLeft" name="scoreSample" type="text" ng-model="scoreSample" id="scoreSample" ng-change="sampleMethod()" ng-model-onblur>
</td>
<td>
<input only-numeric class=" floatLeft" name="errorSample" type="text" ng-model="errorSample" id="errorSample" ng-change="sampleMethod()" ng-model-onblur>
</td>
</tr>
AngularJS 代码:
$scope.sampleMethod = function () {
alert("Coming here");
}
提前致谢。
【问题讨论】:
-
你能发布你的代码吗?
-
嗨,马克,我已经发布了代码。
-
你在哪里定义了
sampleMethod函数?顺便说一句,input 不能有结束标签;) -
@tanuj 确保您的 ng-model 表达式中有一个点 (!)
-
我认为你必须发布整个视图和控制器,以便我们知道发生了什么。
标签: angularjs twitter-bootstrap textbox