angular-chosen icon indicating copy to clipboard operation
angular-chosen copied to clipboard

TypeError: n.chosen is not a function

Open eugenevk opened this issue 7 years ago • 6 comments

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?

eugenevk avatar Dec 15 '17 12:12 eugenevk

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)

adityasharat avatar Dec 15 '17 12:12 adityasharat

Hi @adityasharat, unfortunately that doesn't solve it. Same error. I copied the master into my lib directory.

eugenevk avatar Dec 15 '17 13:12 eugenevk

Have you included jQuery and chosen before angular?

adityasharat avatar Dec 15 '17 13:12 adityasharat

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

eugenevk avatar Dec 15 '17 13:12 eugenevk

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 */
...

adityasharat avatar Dec 16 '17 10:12 adityasharat

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

robe2 avatar Aug 28 '19 10:08 robe2