Angularjs - after I enter a value into a <intput> field with ng-model the value changes to undefined

ⅰ亾dé卋堺 提交于 2019-12-13 08:18:35

问题


I have a simple form that accepts an input. For some reason when I change the value the scope variable changes to undefined.

<body ng-controller="myctrler">
<input ng-model="t.unsubscribeEmail" type="email" class="textboxfields" placeholder="Enter email address">
</body>

In the controller:

$scope.k=
{
    unsubscribeEmail : "not"
};

The value before I enter anything into the inputbox is "not". As soon as I type something in the input the value changes to undefined.

What am I missing?


回答1:


Change your input type text or write valide email

<input ng-model="t.unsubscribeEmail" type="text" class="textboxfields" placeholder="Enter email address">

or write valide email in

<input ng-model="t.unsubscribeEmail" type="email" class="textboxfields" placeholder="Enter email address">


来源:https://stackoverflow.com/questions/26324666/angularjs-after-i-enter-a-value-into-a-intput-field-with-ng-model-the-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!