AngularJS not compatible with Angular Material

Visit this link for more details

Encountering an error while using angular-material: Uncaught Error: [$injector:unpr] here's the error message$injector/unpr?p0=%24%24forceReflowProvid…eQueue%20%3C-%20%24animate%20%3C-%20%24compile%20%3C-%20%24%24animateQueue

Routing.JS :

(function () {
    var app = angular.module('angularMaterial', ['ngRoute','ngMaterial']);
    app.config(function ($routeProvider) {
        $routeProvider
            .when("/main", {
                templateUrl: 'main.html',
                controller: 'MainController'
            })
            .otherwise({ redirectTo: "/main" });

    });
}());

Index.html : Shell for displaying html pages based on routing

<html lang="en" ng-app="angularMaterial">

  <head>
    <title>Angular Material Fundamentals</title>
    <meta charset="utf-8" />
    <link data-require="angular-material@*" data-semver="1.1.0" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css" />
    <script data-require="angular-material@*" data-semver="1.1.0" src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
    <script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4a5aaa3b1a8a5b6eaaeb784f5eaf2eaf4">[email protected]</a>" data-semver="1.6.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.js"></script>
    <script data-require="angular-animate@*" data-semver="1.6.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular-animate.js"></script>
    <script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="14757a73617875663975667d7554253a213a21">[email protected]</a>" data-semver="1.5.5" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
    <script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f5e51584a535e4d12525a4c4c5e585a4c7f0e110a110a">[email protected]</a>" data-semver="1.5.5" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
    <script src="routing.js"></script>
    <script src="MainController.js"></script>
  </head>

  <body ng-cloak="">
    <header>
      <h1>
        Angular Material Fundamentals </h1>
    </header>
    <div ng-view=""></div>
  </body>

</html>

Main.html :

<div>

    <md-content flex layout-padding>
        {{message}}
    </md-content>


</div>

MainController.js :

function MainController($scope) {
    $scope.message = "Angular Material is a UI component library for Angular JS developers. Angular Material components helps in constructing attractive, consistent, and functional web pages and web apps while adhering to modern web design principles like browser portability, device independence, and graceful degradation. It helps in creating faster, beautiful, and responsive websites. It is inspired from Google Material Design.";

}


MainController.$inject = ['$scope'];
angular.module('angularMaterial').controller('MainController', MainController);

In need of assistance, thank you.

Answer №1

If you're using Angular material, make sure to include angular.js before adding the angular-material.min.js resource file.

The correct order for adding script resources is:

<script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bcddd2dbc9d0ddce92d6cffc8d928a928c">[email protected]</a>" data-semver="1.6.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.js"></script>
<script data-require="angular-material@*" data-semver="1.1.0" src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>

For a live example, check out this Plunker: http://plnkr.co/edit/D8KNdE4phpxwCf6N5s4x?p=preview

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to handle the res.locals object in a request manipulation

I am currently utilizing node-restful in my project and I am looking to replace my date properties with the help of moment. However, when I attempt the following approach; var QuestionResource = app.user = restful.model('Question', questionSche ...

Having trouble switching states in React

Can anyone assist me with a code issue I'm facing when trying to run it onClick? The desired functionality is for each button to display the names set in the 'useState' state, which should then change to 'Click on close' when click ...

Tips for integrating custom images or icons into Onsen-UI:

I am currently utilizing the Onsen-UI framework along with AngularJS to create a mobile application. I want to incorporate custom images for buttons, but they appear blurry or unclear on certain mobile devices when the app is launched. Below is my code sn ...

The button must stay deactivated even if the page is refreshed

When I click on the submit button, it disables for 15 seconds before getting enabled again. However, if I refresh the page, the button becomes immediately enabled without waiting the disable time. Can someone please assist me with this issue? $(window). ...

Is there a discrepancy in the value between data and computed properties in Vue components?

Upon reviewing my code, I have noticed that the value shown in the data of the component does not match the desired value. The code snippet is provided below: View.component('xxx-item',{ props:['item'], template:`xxxx`, computed: ...

Tips for correctly appending a span element

I am trying to implement an icon of valid or error to be appended to the input, similar to the example shown on http://getbootstrap.com/css/#forms-control-validation. Here is the code I have written for this purpose: $(document).ready(function(){ $(&a ...

Unable to locate the JavaScript files within the NextJs and ReactJs project

I've encountered an issue when trying to import js files (which are libraries) in my project. I am currently using NextJS version 14.1.3 and ReactJS version 18.2.0. You can find the path to these files here Here is a glimpse of the project structure ...

Text that changes within a set-sized box

I'm working with a fixed-size div that contains dynamically generated text. Is there an easy method using DOJO or plain Javascript to truncate the text before the end of the div and add "..."? How can I accomplish this regardless of the font size bein ...

Discovering the index of an item in Angular

My delete function emits socket.io to update the other party's items list and remove the specific item. The issue arises when I receive the socket data as I struggle to find the matching item to update it. Logic User 1 deletes a message User 2 receiv ...

How does the rest operator in Javascript work when dealing with a different array input?

The following code snippet shows a function that uses Insertion Sort to sort an array of heights. The values being passed in are 4, 1, 9, 14, 6, and 8, and the sorted order should be 1, 4, 6, 8, 9, 14. var heightChecker = function(heights) { var sorte ...

Challenge: Issue with ng-required in Angular when using a custom directive

I am currently utilizing Angularjs version 1.5 for input validation within my form. The use of ng-required is essential for validating all required inputs. Nevertheless, I am encountering an issue with a custom directive that generates a combo box. This ...

Display or conceal a div element depending on the value selected in Vue.js

I have a Vue.js dropdown and I would like to show or hide my div based on the selected value in the dropdown. The current code is only working for one ID, but I want it to work for all IDs. I want to toggle the visibility of my div based on the option&apos ...

How can one effectively manage asynchronous behavior on the client side of a Meteor application?

My focus is on Meteor. I want to connect with the Facebook API through Meteor's HTTP in order to show images on Meteor's client side. I've come across suggestions like Fiber Futures, storing data in Sessions, and triggering a synchronous se ...

There is an issue with the sorting function: [orderBy:notarray]. The expected input was an array

Looking to incorporate pagination functionality from this source: http://jsfiddle.net/SAWsA/11/ [ { "name": "Micro biology", "id": "2747c7ecdbf85700bde15901cf961998", "category": "Other", "type": "Mandatory - No Certification", "cate ...

How can nested arrays be utilized in Angular 2 reactive forms?

After successfully using a tutorial to create reactive forms in Angular 2, I encountered a new challenge. The tutorial helped me set up an 'Organisation' form with an array of 'Contact' groups, but now I am struggling to add an array wi ...

Tips for managing and authenticating communication between the backend and the frontend

I've built a backend system for user registration and login, but I'm struggling with handling and verifying sessions on the server side. Although I've read some guides on generating session tokens, I'm unsure about how to validate thes ...

The JSON parsing failed due to an expected '}' character missing

I'm in the process of making an ajax request $.ajax({ url: 'url', data: {}, method: 'POST', enctype: 'multipart/form-data', dataType: 'json', success: function(data){ // handle success ...

When using React Router, redirect to a new page by pushing into the browser's history

Is it feasible to utilize <link> for the purpose of <Link to="route" target="_blank"> in order to open links in a new tab? However, can we also employ browserHistory.push to achieve the same outcome? ...

Ways to restrict a function to a single DOM element using either its id or class

This script is responsible for dynamically loading pages on my website. It works fine, except that it currently iterates over all anchor tags a on the site, whereas I want it to iterate only through my navigation menu. Here is the navigation menu: <div ...

What steps should I take to enable Google Maps style on mobile devices?

Hi there! I'm having some trouble styling my Google map. Sometimes the style loads correctly in browsers, and sometimes it doesn't. Another issue I've noticed is that when I view the page on mobile platforms like Android Chrome, iOS Safari, ...