ng-model created with ng-bind-html
how to watch for ng-model created with ng-bind-html
HTML
<script src="http://ci.angularjs.org/job/angular.js-angular-master/ws/build/angular.js"></script>
<script src="http://ci.angularjs.org/job/angular.js-angular-master/ws/build/angular-sanitize.js"></script>
<div ng-app="myApp">
<div ng-controller="bindCtrl">
<div class="testContent">
<div class="test">
<div class="questions" ng-repeat="item in questions" ng-show="questions.length" >
<div ng-bind-html="item.question"></div>
<div compile class="options" ng-bind-html="item.options">
</div>
</div>
</div>
</div>
<div class="watch">scope updated:<br/>{{q|json}}</div>
</div>
</div>
CSS
/******** tests **********/
.testContent{
font-size:12px;
width:65%;
margin:0 auto;
float:left;
text-align:justify;
}
.testContent h2{text-align: center;}
.testContent .questions p, .testsImgs{
margin-left:25px;
}
.testsImgs{
width:325px;
}
.test{
background-color:#EFEFEF;
border:1px solid #d3d3d3;
padding:10px;
border-radius:4px;
}
.options{
margin-top:10px;
margin-bottom:10px;
}
.options input[type='text']{margin-left:5px;}
.watch{font-size:10px;}
JavaScript
var app = angular.module('myApp', ['ngSanitize'])
.controller('bindCtrl', ['$scope', '$http', '$sce', function($scope, $http, $sce){
$scope.q = {1: 'ni ma'};
$scope.questions = [];
$scope.$watch('q', function(n, o){
//do something
});
var data = $.param({
json: JSON.stringify({
'test':{
'1':{
'question':'<span>1. something:</span>',
'options':'<input type="radio" name="q1" ng-model="q[\'1\']" value="a">a) op 1<br><input type="radio" name="q1" ng-model="q[\'1\']" value="b">b) op 2<br><input type="radio" name="q1" ng-model="q[\'1\']" value="c">c) op 3<br><input type="radio" name="q1" ng-model="q[\'1\']" value="d">d) op 4<br><input type="radio" name="q1" ng-model="q[\'1\']" value="e">e) op 5<br>'
},
'2':{
'question':'<span>2. something:</span>',
'options':'<input type="radio" name="q2" ng-model="q[\'2\']" value="a">a) op 1<br><input type="radio" name="q2" ng-model="q[\'2\']" value="b">b) op 2<br><input type="radio" name="q2" ng-model="q[\'2\']" value="c">c) op 3<br><input type="radio" name="q2" ng-model="q[\'2\']" value="d">d) op 4<br><input type="radio" name="q2" ng-model="q[\'2\']" value="e">e) op 5<br>'
}
}
})
});
$http.post("/echo/json/", data).success(function(data, status){
angular.forEach(data.test, function(value, key){
var q = data.test[key];
q[key] = key;
q.question = $sce.trustAsHtml(q.question);
q.options = $sce.trustAsHtml(q.options);
$scope.questions.push(q);
});
}).error(function(data, status){console.log(status)});
}]);
app.directive('compile',function($compile, $timeout){
return{
restrict:'A',
link:...