gpt4 book ai didi

javascript - 急性选择: ac-options and ac-model attributes must be set in Angular Js

转载 作者:行者123 更新时间:2023-12-03 04:09:39 26 4
gpt4 key购买 nike

我需要急性选择。我已经提到了这个enter link description here

添加所有这些依赖项后控制台出现错误

MainPage.html

<ac-select ac-model='hospitalData.hospitalName' 
ac-options='hospital.hospitalName as hospital.hospitalName for hospital in hospNameList'
ac-change='selectionChanged(value)'
ac-settings='{ loadOnOpen: true }'></ac-select>

Error

ac-options and ac-model attributes must be set <ac-select ac-model="hospitalData.hospitalName" ac-options="hospital.hospitalName as hospital.hospitalName for hospital in hospNameList" ac-change="selectionChanged(value)" ac-settings="{ loadOnOpen: true }" class="ng-isolate-scope">

Controller.js

scope.hospitalData=null;
scope.hospitalData.hospitalName=null;
scope.hospNameList=null;
//added above after refferring issue on github,But still not working

gethospNameList();
function gethospNameList() {
Repository.gethospNameList().then(
function(result) {
scope.hospNameList = result;
console.log("hospNameList :"+ scope.hospNameList);
});
};

最佳答案

这是使用angular-ui-select的解决方案

以下只是一个片段

检查柱塞的工作代码:

var app = angular.module('myApp', ['ui.select']);
app.controller('myCtrl', function($scope) {
$scope.superhero = {
selected: 'Sravan'
};

$scope.getSuperheroes = function(search) {
var newSupes = $scope.superheroes.slice();
if (search && newSupes.indexOf(search) === -1) {
newSupes.unshift(search);
}
return newSupes;
}

$scope.superheroes = [
'Sravan',
'Hema',
'AnotherUser',

];
});

<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css">
<script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="select.js"></script>
<link rel="stylesheet" href="style.css">

<body>
<div ng-app="myApp">
<div ng-controller="myCtrl">
<div class="row">
<div class="form-group">
<div class="col-sm-6">
<ui-select ng-model="superhero.selected">
<ui-select-match placeholder="Select or search a superhero ...">{{$select.selected}}</ui-select-match>
<ui-select-choices repeat="hero in getSuperheroes($select.search) | filter: $select.search">
<div ng-bind="hero"></div>
</ui-select-choices>
</ui-select>
</div>
<label class="col-sm-3 control-label">You have chosen {{ superhero.selected }}!</label>
</div>
</div>
</div>
</div>
</body>

</html>

Here is a working Plunker

关于javascript - 急性选择: ac-options and ac-model attributes must be set in Angular Js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44382369/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com