Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: n.chosen is not a function #39

Open
eugenevk opened this issue Dec 15, 2017 · 6 comments
Open

TypeError: n.chosen is not a function #39

eugenevk opened this issue Dec 15, 2017 · 6 comments

Comments

@eugenevk
Copy link

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?

@adityasharat
Copy link
Owner

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)

@eugenevk
Copy link
Author

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

@adityasharat
Copy link
Owner

Have you included jQuery and chosen before angular?

@eugenevk
Copy link
Author

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

@adityasharat
Copy link
Owner

adityasharat commented Dec 16, 2017

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

@robe2
Copy link

robe2 commented Aug 28, 2019

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.

``

<script src="lib/jquery/jquery-3.2.1.min.js"></script> <script src="lib/jquery-ui/jquery-ui.min.js"></script> <script src="lib/chosen/chosen.jquery.min.js" type="text/javascript"></script> <script src="lib/chosen/docsupport/prism.js" type="text/javascript"></script> <script src="lib/angular-chosen/angular-chosen.min.js" type="text/javascript"></script>

``
Where the chosen library you get from - https://github.com/harvesthq/chosen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants