2017-07-27 1800 views
1

我是新来的打字稿。 我有一个angularjs控制器,我试图转换为打字稿控制器。拒绝从'* .ts'执行脚本,因为它的MIME类型('video/vnd.dlna.mpeg-tts')不可执行

首先我声明的控制器和模块

/// <reference path='../../Scripts/typings/angularjs/angular.d.ts' /> 
/// <reference path='../../Scripts/typings/jquery/jquery.d.ts' /> 
'use strict' 

interface IRouteParams extends ng.route.IRouteParamsService { 
    propertyAddress: string; 
} 

class Controller1 { 
    public propertyAdd: string; 
    constructor($scope: any, 
     $routeParams: IRouteParams, 
     ServicesFactory, 
     growl, 
     blockUI, 
     IMAGE_RELATED_MESSAGES, 
     BUSY_MESSAGES, 
     $timeout: ng.ITimeoutService, 
     $modal, 
     Lightbox, 
     $filter) { 

     this.propertyAdd = $routeParams.propertyAddress; 

    } 
} 

angular.module('Controller').controller('Controller1', Controller1); 

,当我在浏览器中运行该代码,我得到以下错误

拒绝执行从“http://localhost/....../Controller1.ts”脚本,因为它的MIME类型(“视频/vnd.dlna.mpeg-tts')不可执行。

什么是痛点?

回答

2

您必须将您的打字稿代码转换为常规的JavaScript代码。 TypeScript不应该直接在浏览器中运行。

使用tsc编译器生成的JavaScript是这样的:在official site

tsc helloworld.ts 

更多细节。

相关问题