0
我已經升級2.0.3昨天打字原稿,並使用下面的命令無效「參考」指令語法參考角時1.5
安裝用於角的1.5倍分型之後更新所述參考路徑/// <reference types="angular" />
錯誤
npm install -s @types/angular
我在構建項目時遇到錯誤,錯誤消失。
無效的 '參考' 指令語法
一個人怎麼解決這個問題?
/// <reference types="angular" />
/// <reference types="d3" />
(function() {
'use strict';
var app = angular.module('charts', []);
app.controller('mainCtrl', function mainCtrl($scope, appService) {
var vm = this;
vm.data1 = [1, 2, 3, 4];
vm.data2 = [4, 5, 7, 11];
vm.update = function (d, i) {
vm.data1 = appService.GetRandomData();
console.log('new data1', vm.data1);
};
vm.update2 = function (d, i) {
vm.data2 = appService.GetRandomData();
console.log('new data2', vm.data2);
};
});
app.directive('barChart', function ($timeout) {
var chart = d3.custom.barChart();
return {
restrict: 'E',
replace: true,
scope: true,
bindToController: {
data: '=',
},
controller: 'mainCtrl',
controllerAs: 'ctrl',
link: function (scope, element, attrs, ctrl) {
var chartEl = d3.select(element[0]);
chartEl.datum(ctrl.data).call(chart)
}
}
});
app.directive('chartForm', function() {
return {
restrict: 'E',
replace: true,
controller: 'mainCtrl',
templateUrl: 'chartform.html'
}
});
app.service('appService', function() {
this.GetRandomData = function() {
var rdata;
rdata = d3.range(~~(Math.random() * 50) + 1).map(function (d, i) {
return ~~(Math.random() * 100);
});
return rdata;
}
});
}());
請張貼實際的代碼,而不是它 –
照片,我添加的代碼。 – Animesh