I am new to typescript. I have an angularjs controller which I am trying to convert to typescript controller.
To start with I declared the controller and module
/// <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);
when I run this code in browser I get following error
Refused to execute script from 'http://localhost/....../Controller1.ts' because its MIME type ('video/vnd.dlna.mpeg-tts') is not executable.
whats is the pain point?
You have to transpile your typescript code to a regular javascript code. TypeScript is not supposed to run directly in the browser.
Use tsc
compiler to produce javascript like this:
tsc helloworld.ts
More details on the official site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With