[英]Angular $Scope Deconstructing Patterns Error
我正在嘗試像此控制器文件一樣將一些數據硬編碼到我的有角$ scope中:
(function() {
'use strict';
angular
.module('app.public')
.controller('PublicController', Controller);
/** @ngInject */
function Controller($scope, $log, app_media) {
$scope.tags = [{
name = 'clock'
}, {
name = 'eye'
}, {
name = "ball"
}];
}
})();
當我在視圖中使用它時,它看起來像這樣:
<md-grid-list md-gutter="1em" md-row-height="20px" md-cols="3">
<md-grid-tile ng-repeat="tag in tags" class="repeated-item">
{{tag.name}}
</md-grid-tile>
</md-grid-list>
但可惜,我在chrome控制台中遇到此錯誤: "Shorthand property assignments are valid only in destructuring patterns"
這是什么意思,我該如何解決? 我研究了解構模式,它看起來像是能夠將對象文字分配給變量的語法? 謝謝! :)
您的tags
列表不正確。 屬性應使用:
分配, :
所示:
$scope.tags = [
{ name: 'clock' },
{ name: 'eye' },
{ name: "ball" }
];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.