尝试使用ngMaterial,但我得到$ injector:modulerr错误

时间:2016-07-16 13:20:20

标签: javascript angularjs material-design angular-material

我今天开始使用角度素材,但是当我想在myproject中使用ngMaterial时,我得到an error ...

我尝试在本地使用角度材质,我的意图非常简单:使用<md-button>

<div ng-app="MyApp" class="buttondemoBasicUsage" ng-controller="AppCtrl" ng-cloak="">
    <md-content>

        <section layout="row" layout-sm="column" layout-align="center center" layout-wrap="">
            <md-button>{{title1}}</md-button>
            <md-button md-no-ink="" class="md-primary">Primary (md-noink)</md-button>
            <md-button ng-disabled="true" class="md-primary">Disabled</md-button>
            <md-button class="md-warn">{{title4}}</md-button>
            <div class="label">Flat</div>
        </section>
    </md-content>
</div>

我添加了我怀疑可以解决我的问题的每个脚本:

<script type="text/javascript" src="/desktopmodules/Barrizon/Scripts/Angular1.x/angular.min.js"></script>
<script type="text/javascript" src="/desktopmodules/Barrizon/Scripts/Material/angular-animate.min.js"></script>
<script type="text/javascript" src="/desktopmodules/Barrizon/Scripts/Material/angular-messages.min.js"></script>
<script type="text/javascript" src="/desktopmodules/Barrizon/Scripts/Material/angular-aria.min.js"></script>
<script type="text/javascript" src="/desktopmodules/Barrizon/Scripts/Material/angular-material.min.js"></script>
<script type="text/javascript" src="/DesktopModules/mvc/Barrizon/LArticle/List/Resources/JS/Barrizon.LArticle.Settings.js"></script>

和最后一个js(Barrizon.LArticle.Settings.js)是我在那里写我的自定义js:

angular.module('MyApp', ['ngAria', 'ngMessages', 'ngMaterial', 'material.svgAssetsCache'])

.controller('AppCtrl', function ($scope) {
    $scope.title1 = 'Button';
    $scope.title4 = 'Warn';
    $scope.isDisabled = true;

    $scope.googleUrl = 'http://google.com';

});

有谁知道我怎么能传递这个错误?

非常感谢

1 个答案:

答案 0 :(得分:2)

您需要在代码中添加所有这些脚本以及自定义js

<script data-require="angular.js@1.4.x" src="https://code.angularjs.org/1.4.9/angular.js" data-semver="1.4.9"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-messages.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.9/angular-material.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-aria.js"></script>
    <script src="http://ngmaterial.assets.s3.amazonaws.com/svg-assets-cache.js"></script>

Plunker:http://plnkr.co/edit/ZWUIiLRaJOvC5WMrMZQq?p=preview