1

Hi guys im just setting up a new project for some work im doing trying to get something working quickly to keep momentum up. However i seem to be having a problem with getting Angular Material to load properly. Im using Node and bower to get my modules which seems to be loading them fine.

However when ever im loading up the page my console reports that its hitting an unreachable code after a return statement like the title suggests. this is actually being hit in the angular material js file that is being imported by bower.

I have no idea why this is happening and any help to progress past this point would be brilliant thank you.

EDIT

I possibly have found a fix to the issue I was having. The backend of the web application I was using was controlled by Django and there was a conflict between Angular js and Django in that they were using the same tags to show values for variables. This was stopping Angular Material from instantiating properly. I still get the unreachable code warning but now Material is working as I expect it to.

I hope this helps some people debug the problems they are having when seeing this issue.

3
  • Is this in Firefox? That's just a warning that there's some useless extra code that won't impact anything. You're likely doing something else wrong, like forgetting your ng-app, main module, or ngMaterial dependency.
    – Bryan K
    Jan 28, 2016 at 15:25
  • 3
    I have the same issue. Using Firefox on Ubuntu. Problem appears in line "opts.menuContentEl[0].addEventListener('click', captureClickListener, true);" of the angular-material modul. Dependency is set properly and everything else works fine.
    – sasha
    Jan 29, 2016 at 16:21
  • I found a solution to the problem i was having and have edited my question to reflect what I found hope this helps others. Jan 30, 2016 at 13:44

1 Answer 1

2

Include the minified version of the library. Automatic Semicolon Insertion is different depending on your browser, if the library code has a return statement broken across two lines, it might end up with a semicolon where one shouldn't be. Using the minified version fixes this because the statement won't be broken across lines.

Include this:

<script src="bower_components/angular-material/angular-material.min.js"></script>

Instead of this:

<script src="bower_components/angular-material/angular-material.js"></script>

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.