Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Angular UI Select2初始化失败_Angularjs_Angular Ui - Fatal编程技术网

Angularjs Angular UI Select2初始化失败

Angularjs Angular UI Select2初始化失败,angularjs,angular-ui,Angularjs,Angular Ui,我无法使Angular UI Select2模块正常工作。下面是我能想到的最简单的例子,来自AngularJS教程 Github项目()中的说明说明,我只需要包括jQuery、Angular和Angular UI的select2.js。但我得到的只是错误: TypeError:对象[Object]没有方法“select2” 包括Select2没有错误,但我得到了select标签的占位符文本作为链接,然后是两个空文本输入字段和一个常规的select下拉列表。当我在“选择”下拉列表中选择某个内容时,

我无法使Angular UI Select2模块正常工作。下面是我能想到的最简单的例子,来自AngularJS教程

Github项目()中的说明说明,我只需要包括jQuery、Angular和Angular UI的select2.js。但我得到的只是错误: TypeError:对象[Object]没有方法“select2”

包括Select2没有错误,但我得到了select标签的占位符文本作为链接,然后是两个空文本输入字段和一个常规的select下拉列表。当我在“选择”下拉列表中选择某个内容时,它的值将替换占位符文本。单击链接会清空页面,尝试在文本框中输入内容也会清空页面

我已经在多个浏览器和平台上进行了测试,以Yeoman的GeneratorAngular为基础。我尝试了Angular UI的select2.js的旧版本,但行为没有改变。搜索并没有找到任何相关的东西,我找到的工作示例是AngularUI分解成模块之前的

我做错了什么,还是这是一个错误

html:


如果您得到“没有方法选择2”,请尝试在
angular.js
之前包含
select2.js


此外,您还需要
select2.css
文件。它不会神奇地改变自己的风格:)

如果您得到“没有方法选择2”,请尝试在
angular.js
之前包含
select2.js


此外,您还需要
select2.css
文件。它不会神奇地改变自己的风格:)

Duh。好。当然非常感谢。我可以发誓我在某个时候有一些CSS,但这可能是AngularUI的完整包。。。生活和学习。我将尝试在项目的Github directions.Duh中对此进行更改。好。当然非常感谢。我可以发誓我在某个时候有一些CSS,但这可能是AngularUI的完整包。。。生活和学习。我将尝试在项目的Github方向上改变这一点。
<!doctype html>
<html ng-app="anguish">
<head>
<script type="text/javascript" src="components/jquery/jquery.js"></script>
<script src="components/angular/angular.js"></script>
<script type="text/javascript" src="components/select2/select2.js"></script>
<script type="text/javascript" src="components/angular-ui-select2/src/select2.js"></script>
<script type="text/javascript" src="foo.js"></script>
</head>
<body>
<div>
<select ui-select2 ng-model="select2" data-placeholder="Pick a number">
    <option value=""></option>
    <option value="one">First</option>
    <option value="two">Second</option>
    <option value="three">Third</option>
</select>
</div>
</body>
</html>
'use strict';

angular.module('anguish', ['ui.select2'])
.controller('MainCtrl', function ($scope) {
    $scope.select2 = null;
    $scope.select2Options = {
        allowClear:true
    };
});