Angular Material md-menu无法读取属性' setAttribute'为null

时间:2016-01-12 09:47:58

标签: javascript angularjs menu angular-material

我正在使用Angular Material,当我在我的应用程序中放入md菜单时,会显示错误。这是错误:

 TypeError: Cannot read property 'setAttribute' of null

代码:

<md-menu>
   <md-button ng-click="$mdOpenMenu($event)" class="md-icon-button" aria-label="Open sample menu">
       <md-icon md-svg-icon="call:phone"></md-icon>
   </md-button>
   <md-menu-content>
       <md-menu-item>
            <md-button ng-click="doSomething()">Do Something</md-button>
       </md-menu-item>
   </md-menu-content>
</md-menu>

我正在使用凉亭,当我将角度材料的版本从0.11.0上传到1.0.1时,错误开始出现。这是我的bower.json:

{
    "name": "Angular-Base",
    "dependencies": {
    "angucomplete-alt": "~1.1.0",
    "angular": "~1.4.0",
    "angular-animate": "~1.4.3",
    "angular-aria": "~1.4.3",
    "angular-chart.js": "~0.7.2",
    "angular-drag-and-drop-lists": "~1.2.0",
    "angular-emoji": "~0.1.0",
    "angular-emoji-filter-hd": "~0.0.6",
    "angular-material": "1.0.1",
    "angular-md5": "~0.1.8",
    "angular-messages": "~1.4.7",
    "angular-sanitize": "~1.4.3",
    "angular-ui-router": "0.2.15",
    "hint.css": "~1.3.5",
    "jquery-legacy": "jquery#1.11.3",
    "moment": "~2.10.6",
    "ng-file-upload": "~6.2.1",
    "ngWYSIWYG": "*",
    "angular-material-data-table": "0.9.7",
    "perfect-scrollbar": "~0.6.8"
},
"devDependencies": {
    "angular-translate": "~2.7.2",
    "angular-translate-loader-static-files": "~2.7.2"
},
"resolutions": {
    "angular": "1.4.7",
    "angular-sanitize": "~1.4.3"
}

我也阅读并测试this question但没有成功......

提及一切正常并在菜单中工作(点击操作也很好),但每次我放一个md菜单时都会在控制台中显示该错误...所以我想解决这个问题...

谢谢!

1 个答案:

答案 0 :(得分:2)

解决! :)

我正在使用gulp任务(gulp-minify-html节点模块)来处理html,这个模块在所有角标签之前插入字符串'data'。所以在我的代码中我没有看到该前缀,但生成的代码有它。

最后,this question有答案。