angular-chosen
angular-chosen copied to clipboard
TypeError: n.chosen is not a function
Hi,
I get the above error in my angular MEAN project. Have installed via bower and included dependency:
,'public/lib/angular-chosen-js/angular-chosen.min.js'
and
,'angular.chosen'
Can you advise?
Hey @eugenevk, I remember there was some issue with bower. I recommend using the library directly. (by cloning the repo into your vendor or lib directory)
Hi @adityasharat, unfortunately that doesn't solve it. Same error. I copied the master into my lib directory.
Have you included jQuery and chosen before angular?
I have now included this:
...
'public/lib/jquery/dist/jquery.min.js'
,'public/lib/jquery-ui/jquery-ui.min.js' // needed by ui-sortable
,'public/lib/bootstrap/dist/js/bootstrap.js'
,'public/lib/angular-chosen/angular-chosen.min.js'
,'public/lib/angular/angular.js'
...
But that returns the following error:
Uncaught ReferenceError: angular is not defined at angular-chosen.min.js:29
The issue is the order I suppose
...
'public/lib/jquery/dist/jquery.min.js'
,'public/lib/jquery-ui/jquery-ui.min.js' // needed by ui-sortable
,'public/lib/bootstrap/dist/js/bootstrap.js'
,'public/lib/angular/angular.js'
,'public/lib/angular-chosen/angular-chosen.min.js' /* after angular */
...
I had the same issue. I didn't realize the chosen library wasn't bundled in this angular-chosen directive until I looked at the example. So to fix I had to do this.
``
`` Where the chosen library you get from - https://github.com/harvesthq/chosen