Probably silly question, but I have my html form with simple input and button:
(可能是愚蠢的问题,但我的html表单有简单的输入和按钮:)
<input type="text" ng-model="searchText" />
<button ng-click="check()">Check!</button>
{{ searchText }}
Then in the controller (template and controller are called from routeProvider):
(然后在控制器中(从routeProvider调用模板和控制器):)
$scope.check = function () {
console.log($scope.searchText);
}
Why do I see the view updated correctly but undefined in the console when clicking the button?
(为什么我在单击按钮时看到视图更新正确但在控制台中未定义?)
Thanks!
(谢谢!)
Update: Seems like I have actually solved that issue (before had to come up with some workarounds) with: Only had to change my property name from searchText
to search.text
, then define empty $scope.search = {};
(更新:好像我其实已经解决了这个问题(必须想出一些解决方法前):只有从改变我的属性名称searchText
到search.text
,然后定义空$scope.search = {};
)
object in the controller and voila... Have no idea why it's working though ;](控制器中的对象和瞧...不知道为什么它正在工作;])
ask by alchemication translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…