After spending a year coding Angular and seeing great progress, the buzz around TypeScript has caught my attention. While there are plenty of tutorials and blogs on the topic, there seems to be inconsistency in the recommendations. How should the app.js file be structured for TypeScript?
angular.module('angular10App', [
'ngCookies',
'ngResource',
'ngSanitize',
'ui.router',
'ui.bootstrap',
'ngStorage',
'cfp.loadingBar',
'ngAnimate'
])
.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider
.otherwise('/');
$locationProvider.html5Mode(true);
});
As for the controller, I aim to remove scope from it by using 'Controller as vm' in the route config. What would be the ideal structure for this controller?
angular.module('angular10App')
.controller('ResultsCtrl', function ($scope, $stateParams, results) {
$scope.flightType = $stateParams.flightType;
$scope.selectedAirportDep = $stateParams.from;
$scope.selectedAirportRet = $stateParams.to;
$scope.depDate = $stateParams.depDate;
$scope.arrDate = $stateParams.arrDate;
$scope.class = $stateParams.class;
$scope.adults = $stateParams.adults;
$scope.children = $stateParams.children;
$scope.results = results;
});