Wednesday, 11 September 2013

Error in statement: return item.name.contains('$scope.inputQuery') ;

Error in statement: return item.name.contains('$scope.inputQuery') ;

The html(jade) contains
body(ng-controller='myAppController')
<input ng-model="inputQuery">
ul
li(ng-repeat="phone in phones|filter:query") {{phone.name}}
p {{phone.snippet}}
the controller is defined as:
function myAppController($scope){
$scope.query = function(item){
return item.name.contains('$scope.inputQuery') ;
}
$scope.phones = [
{"name": "Nexus S",
"snippet": "Fast just got faster with Nexus S."},
{"name": "Motorola XOOM™ with Wi-Fi",
"snippet": "The Next, Next Generation tablet."},
{"name": "MOTOROLA XOOM™",
"snippet": "The Next, Next Generation tablet."}
];
}
The output is supposed to be, the 'phone' whose 'name' contains the
'input' letters. However there is no output. (no change depending upon
input either)
Upon inspection, the following works:
$scope.query = function(item){
return item.name; // or return item
}
but even return item.name.contains('N'); does not work

No comments:

Post a Comment