2016-09-23 34 views
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; 
     } 
    }); 

}()); 
+0

請張貼實際的代碼,而不是它 –

+0

照片,我添加的代碼。 – Animesh

回答

0

我已經更新在工作區設置的打字稿路徑文件.vscode/settings.json指向最新版本的打字稿。這將使VS代碼使用最新版本打字稿。

{ 
    "typescript.tsdk": "C:\\Users\\UserName\\AppData\\Roaming\\npm\\node_modules\\typescript\\lib" 
} 

我不認爲這個問題的辦法,因爲當我在集成終端運行tsc -v,我2.0.3

現在我正在修復編譯器錯誤。

幫助鏈接: