I've just started learning angular and got stuck on this problem. I read on AngularJS : Why ng-bind is better than {{}} in angular? that {{}}
and ng-bind
will give you the same outcome. However, it is not the case for the codes below:
JS
(function () {
angular
.module("myApp", [])
.controller("selectCtrl2", function ($scope, $http) {
$http({
method: "GET",
url: "http://localhost/testService/name.php"
})
.then(function (response) {$scope.names = response.data.content;},
function (response) {$scope.names = response.statusText;});
});
})();
HTML
<body data-ng-app="myApp">
<div data-ng-controller="selectCtrl2">
<select>
<option data-ng-repeat="x in names">
<span data-ng-bind="x"></span>
</option>
</select>
</div>
</body>
ng-repeat actually created 3 option tags, but their innerHTML were spaces only. For some weird reasons, if I used {{x}}, their innerHTML would be filled with the text in an array I prepared [a, b, c]. I wonder what could be the reason.