Angular UI-select标记简单字符串标记(启用自定义标签标签和排序)



我正在构建一个食谱网站,该网站在添加标签时使用Angular UI选择,如果尚未在DB上添加到DB。

我下载了AngularJS和Angular UI-select,并将其添加到我的Bundleconfig.cs中,并在我的site.js

中添加了demo.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选择的DIV放在我的html

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

然后我向JS代码添加了$ HTTP

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

最新更新