我无法找到使用下拉菜单中的对象数组使用角度下拉的示例,有人可以帮我调试吗?我最终希望“显示我”成为角度库中的单选按钮列表。
<div ng-app="myApp" ng-controller="myCtrl">
Method:
<select ng-model="selectedName" ng-options="x.name for x in names">
</select>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.names = [{name: 'Experiment'}, {name: 'Clinical Trial'}, {name: 'Case Report'}];
$scope.changeme = function() {
alert('here');
}
});
</script>
<div ng-if = "x.name == 'Experiment'">
<span>Show Me</span>
</div>
答案 0 :(得分:0)
工作版
<div ng-app="myApp" ng-controller="myCtrl">
Method:
<select ng-model="selectedName" ng-options="name.name as
name.name for name in names">
</select>
<div ng-if = "selectedName === 'Experiment'">
<span>Show Me</span>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.selectedName = null;
$scope.names = [{name: 'Experiment'}, {name: 'Clinical Trial'}, {name: 'Case Report'}];
});
</script>
你的问题是你把你的&#34;告诉我&#34;在ng-app之外阻止