【问题标题】:Refused to execute script from '*.ts' because its MIME type ('video/vnd.dlna.mpeg-tts') is not executable拒绝从“*.ts”执行脚本,因为它的 MIME 类型(“video/vnd.dlna.mpeg-tts”)不可执行
【发布时间】:2018-01-02 14:39:27
【问题描述】:

我是打字稿的新手。 我有一个 angularjs 控制器,我正在尝试将其转换为 typescript 控制器。

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

    /// <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 类型 ('video/vnd.dlna.mpeg-tts') 不可执行。

痛点是什么?

【问题讨论】:

    标签: angularjs typescript


    【解决方案1】:

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

    使用tsc 编译器生成这样的javascript:

    tsc helloworld.ts
    

    更多详情请关注official site

    【讨论】:

      猜你喜欢
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-28
      • 2018-10-12
      • 2022-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多