我想實現角ui.select到我的項目使用引導主題,但我沒有什麼,但它的問題。我正在傳遞一些非常簡單的物品。 這裏是我試圖通過角ui.select不呈現項目
[Object { institution_type_id="1", institution_type_description="Post"}, Object { institution_type_id="2", institution_type_description="Security"}, Object { institution_type_id="3", institution_type_description="Mutual Fund"}, Object { institution_type_id="4", institution_type_description="Bank"}, Object { institution_type_id="5", institution_type_description="Life insurance"}]
它使用的是常規選擇,如下圖所示呈現的微小物體。
我想使用的角度,而不是ui.select,這裏是我的設置.. 我已經包含在我的主網頁下面
<!-- Angular ui-select -->
<link rel="stylesheet" href="../bower_components/ui-select/dist/select.min.css" type="text/css" />
<!-- Angular ui-select -->
<script src="../bower_components/ui-select/dist/select.min.js"></script>
<script src="../bower_components/angular-sanitize/angular-sanitize.min.js"></script>
我想用bootstrap主題所以當然引導CSS也被包括在我的app.js
現在,我已經包括了
ui.select
的依賴
這是我在控制器:
institutionService.getAllInstitutionTypes().then(function(data){
$scope.institutionTypes = data;
});
,這裏是我的html的模樣。
<div class="form-group required" ng-class="{ 'has-error': addEditInstitutionForm.institution_type_id.$invalid && addEditInstitutionForm.institution_type_id.$dirty}">
<label for="institution_type_id" class="control-label col-xs-4">Institution Type</label>
<div class="col-xs-8">
<ui-select ng-model="ctrl.country.selected" theme="bootstrap" style="width: 300px;" title="Choose Institution Type">
<ui-select-match placeholder="Select or search institutionType...">{{$select.selected.institution_type_description}}</ui-select-match>
<ui-select-choices repeat="type in institutionTypes">
<span ng-bind-html="type.institution_type_description"></span>
<small ng-bind-html="type.institution_type_id"></small>
</ui-select-choices>
</ui-select>
</div>
當我加載頁面時,它看起來像ui.select已呈現罰款..但下拉內沒有任何內容,如下所示。
我在控制檯中看到很多關於$ sce的錯誤:不安全,如下所示。
問題現在:
- 我怎樣才能修復這些錯誤,以正確地呈現下拉。
- 在代碼片段(http://angular-ui.github.io/ui-select/demo-basic.html)中,他們引用了幾個地方的$ select。有人能幫我理解嗎?
- 我如何驗證角度ui.select,如果我設法解決問題並更好地理解它,以便在我的項目中使用它。
- 有沒有比angular.ui選擇更好,更簡單的選擇?
謝謝。
你是嗎包括某處的某個外部URL?這主要是顯示錯誤的原因。 – Matheno
解決您的問題[這裏](http://stackoverflow.com/questions/18340872/how-do-you-use-sce-trustashtmlstring-to-replicate-ng-bind-html-unsafe-in-angu) –
不,我沒有在外部加載任何東西。所有的CSS和JS文件都從項目文件夾中加載 –