I met a problem about $watch works with ng-modle under ion-content, attach code.
test.html:
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="cordova.js"></script>
<script src="test.js"></script>
<meta charset=utf-8/>
<title>test</title>
</head>
<body ng-controller="MainCtrl">
<ion-pane>
<ion-content>
<input ng-model="name"/>
</ion-content>
</ion-pane>
</body>
</html>
test.js:
app = angular.module('app', ['ionic']);
app.controller('MainCtrl', function($scope) {
$scope.name = "Angular";
$scope.$watch('name', function()
{
alert();
});
});
In this example, $watch doesn’t work, can’t listen ng-model changes, if you comment in test.html, $watch works right.
Is it a bug of ionicframwork or am I wrong. How to fix it?