【问题标题】:Angularjs - Dropdown multiselectAngularjs - 下拉多选
【发布时间】:2015-11-17 12:59:45
【问题描述】:

我正在尝试通过以下方式添加 AngularJS 多选下拉菜单 http://dotansimha.github.io/angularjs-dropdown-multiselect/#/

但我无法得到它..

这是我的 Plunker 代码

http://plnkr.co/edit/7EV9Fc?p=preview

HTML:-

<!DOCTYPE html>
<html>

  <head>
    <link rel="stylesheet" href="style.css">
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"></script>
    <script src="https://github.com/dotansimha/angularjs-dropdown-multiselect/blob/master/src/angularjs-dropdown-multiselect.js"> </script>
    <script src="https://github.com/lodash/lodash/blob/master/dist/lodash.js"></script>
    <script src="script.js"></script>
  </head>

<body ng-app="jayApp" ng-controller='jayController'>

Drop down : 
    <div ng-dropdown-multiselect="" options="example1data" selected-model="example1model">

    </div>

</body>

</html>

Javascript

var jayApp = angular.module('jayApp',[]);

jayApp.controller('jayController', function($scope) {

    $scope.example1model = []; 
    $scope.example1data = [ {id: 1, label: "David"}, {id: 2, label: "Jhon"}, {id: 3, label: "Danny"}];
})

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    在 angular 中包含模块(即在 app.js 中) - angularjs-dropdown-multiselect

    【讨论】:

      【解决方案2】:

      您引用的 GitHub JS 文件不是实际的 JS 文件,而是显示 JS 文件的 GitHub 视图的网页。您需要包含实际的 JS 文件。

      编辑:示例:

      https://github.com/dotansimha/angularjs-dropdown-multiselect/blob/master/src/angularjs-dropdown-multiselect.js

      对比

      https://raw.githubusercontent.com/dotansimha/angularjs-dropdown-multiselect/master/src/angularjs-dropdown-multiselect.js

      【讨论】:

        【解决方案3】:
        var myApp = angular.module("yourAppName", [ "angularjs-dropdown-multiselect" ])
        

        您需要将模块注册到您的应用中。

        您的脚本路径也错误(正如另一位用户所提到的)。

        我知道这已经晚了 4 年,但希望这可以帮助其他仍在使用古老 AngularJS 的人。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-11-21
          • 2019-06-04
          相关资源
          最近更新 更多