Using Angular 1.5.5, I try to use Typescript so I configured gulp tasks successfully ; now I try to make a service in typescript with this code in SampleService.ts:
module app {
class SampleService {
constructor() {
}
public toto() :void {
console.log('test');
}
}
angular.module("app").service("SampleService", [SampleService]);
}
Otherwhere I have :
angular.module('app',
[ 'ngMaterial',
'ngAnimate',
....
In order to declares routes:
$stateProvider
.state('myapp', {
url: '',
controller: 'MainController as vm',
templateUrl: 'app/views/main.html',
abstract: true
})
.state('myapp.search', {
url: '/',
controller: 'SearchController as vm',
templateUrl: 'app/views/partials/search.html'
})
Without this service declaration, everything is working fine. Now with SampleService declared this way, I get:
Error: [ng:areq] Argument 'MainController' is not a function, got undefined
http://errors.angularjs.org/1.5.5/ng/areq?p0=MainController&p1=not%20a%20function%2C%20got%20undefined
minErr/<@http://localhost:3000/bower_components/angular/angular.js:68:12
assertArg@http://localhost:3000/bower_components/angular/angular.js:1880:11
Even if the service is not injected, it seems to break my application. Any idea of what wrong I did?