簡體   English   中英

Angular UI-Select標記簡單字符串標記(啟用自定義標記標簽和排序)

[英]Angular UI-Select tagging Simple String Tags (With Custom Tag Label & Sort Enabled)

我正在建立一個食譜網站,該網站在添加標簽時將使用角度ui-select,如果標簽尚未在數據庫中,則會將其添加到數據庫中。

我下載AngularJS和角度UI的選擇,在我BundleConfig.cs加入它,並添加demo.js代碼在這里我Site.js

BundleConfig.cs

bundles.Add(new ScriptBundle("~/bundles/angular").Include(
"~/Scripts/angular.min.js"));

bundles.Add(new ScriptBundle("~/bundles/select").Include(
"~/Scripts/select.min.js"));

bundles.Add(new ScriptBundle("~/bundles/site").Include(
"~/Scripts/Site.js"));

然后我在HTML中添加了這個

<ui-select multiple tagging tagging-label="(custom 'new' label)" ng-model="ctrl.multipleDemo.colors" theme="bootstrap" sortable="true" ng-disabled="ctrl.disabled" style="width: 300px;" title="Choose a color">
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
<ui-select-choices repeat="color in ctrl.availableColors | filter:$select.search">
    {{color}}
</ui-select-choices>
</ui-select>
<p>Selected: {{ctrl.multipleDemo.colors}}</p>

然后在我的腳本部分

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/angular")
@Scripts.Render("~/bundles/select")
@Scripts.Render("~/bundles/site")
}

但是當我運行它時,我得到的輸出就是這個演示的輸出

{{$item}} {{color}}
Selected: {{ctrl.multipleDemo.colors}}

我也嘗試添加所有css和js鏈接,但是沒有用。

我不知道我在想什么,有人可以幫我嗎?

我嘗試將ng-app和ng-controller放在_Layout.cshtml中,而不是將ui-select包含在html中的div

<html ng-app="app">
<head>
</head>
<body ng-controller="mainCtrl">

然后我將$ http添加到js代碼

var app = angular.module('app', [])
    app.controller('mainCtrl', function ($scope, $window, $http) {

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM