角度ng-change不调用代码.我使用的是错误的模型吗 [英] Angular ng-change not calling code. Am I using wrong model

查看:55
本文介绍了角度ng-change不调用代码.我使用的是错误的模型吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MEAN.js生成器和在网上找到的教程来构建应用程序.在这里,我的一个Angular视图中有一个日期选择器.现在,我希望ng-change指令能够被识别并执行某些操作.当我更改日期时,此处显示的测试警报不会被调用.

I am building an app using MEAN.js generators and a tutorial I found online. Here I have a datepicker in one of my Angular views. For now I would like the ng-change directive to be recognized and do something. At the moment when I make a change to the date my test alert shown here does not get called.

<div class="form-group">
   <label class="control-label" for="statusdate">Status Date</label>
   <div class="controls">
      <input type="date"  ng-change="alert('something')" data-ng-model="statusDate" id="statusdate" class="form-control">
   </div>
</div>

有人可以帮忙吗?我是Angular的新手.

Can somebody help? I am new to Angular.

另外,我在某处读到它可能是因为我使用了data-ng-model而不是ng-model.可能是这样吗?如果是这样,那么两者之间有什么区别?

Also, I read somewhere it may be because I used data-ng-model as opposed to ng-model. Could this be the case? If so then what is the difference between the two?

推荐答案

您正在执行的控制器中不存在的方法.

You are executing a method that does not exist in the controller.

尝试像这样创建它:

$scope.alert = function(msg) {
    alert(msg);
 };

这篇关于角度ng-change不调用代码.我使用的是错误的模型吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆