Reputation: 19896
CODE: http://plnkr.co/edit/H2hmEukfjaPL1T4W298O?p=preview
HTML:
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<link data-require="chosen@*" data-semver="1.0.0" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/chosen/1.0/chosen.min.css" />
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="[email protected]" src="https://code.angularjs.org/1.2.20/angular.js" data-semver="1.2.20"></script>
<script data-require="jquery@*" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="chosen.jquery.js"></script>
<script src="chosen.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<select chosen ng-model="bar">
<option>Hi</option>
<option>This is fun</option>
<option>I like Chosen so much</option>
<option>I also like bunny rabbits</option>
<option value=""></option>
</select>
</body>
</html>
JS:
var app = angular.module('plunker', ['localytics.directives']);
I am not sure why I am getting this:
TypeError: undefined is not a function at http://run.plnkr.co/lPtcBAAKhcfkB6tE/chosen.js:86:26 at https://code.angularjs.org/1.2.20/angular.js:5873:13 at Scope.$eval (https://code.angularjs.org/1.2.20/angular.js:12608:28) at Scope.$digest (https://code.angularjs.org/1.2.20/angular.js:12420:31) at Scope.$apply (https://code.angularjs.org/1.2.20/angular.js:12712:24) at https://code.angularjs.org/1.2.20/angular.js:1419:15 at Object.invoke (https://code.angularjs.org/1.2.20/angular.js:3918:17) at doBootstrap (https://code.angularjs.org/1.2.20/angular.js:1417:14) at bootstrap (https://code.angularjs.org/1.2.20/angular.js:1431:12) at angularInit (https://code.angularjs.org/1.2.20/angular.js:1344:5)
Any clue?
Upvotes: 2
Views: 3103
Reputation: 7666
You need to have jquery before angularjs in this case
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<link data-require="chosen@*" data-semver="1.0.0" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/chosen/1.0/chosen.min.css" />
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="jquery@*" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script data-require="[email protected]" src="https://code.angularjs.org/1.2.20/angular.js" data-semver="1.2.20"></script>
<script src="chosen.jquery.js"></script>
<script src="chosen.js"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<p>Hello {{name}}!</p>
<select chosen ng-model="bar">
<option>Hi</option>
<option>This is fun</option>
<option>I like Chosen so much</option>
<option>I also like bunny rabbits</option>
<option value=""></option>
</select>
</body>
</html>
Upvotes: 2