I am currently in the process of transitioning a component (AngularJS 1.6) from JavaScript to TypeScript.
class NewProjectCtrl {
price: number;
static $inject = ['$http'];
constructor($http) {
let ctrl = this;
ctrl.price = '50';
...
}
createProject() {
$http.post('/api/project', ctrl.project)
...
}
}
angular
.module('app.projects-selection')
.component('newProject', {
templateUrl: 'app/projects-selection/components/new-project/new-project.tmpl.html',
controller: NewProjectCtrl,
bindings: {
user: '<',
}
});
While making this migration, I encountered an issue with TypeScript where it raised an error on $http
within my createProject method (Cannot find name $http). Most examples I found only showcase dependency injections within the constructor.