1

I am pretty new to Angular.JS and Typescript and try to use them together but I am stuck at a point, which should not be a problem for most of you.

Is successfully made route with a view and a controller.

This works perfectly if they are in the some file like this.

var collabClientApp = angular.module('collabClientApp', ['ui.router']);
console.log("started routing");

collabClientApp.config(function ($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise("/projects");
  $stateProvider
    .state('projects', {
      url: "/projects",
      templateUrl: "views/projects.html",
      controller: "ProjectListController"
    })
});

collabClientApp.controller("ProjectListController",
  function ProjectListController($scope) {
    $scope.projects = projects;
  }
);

Then I tried to move the controller to a separate file like this:

/// <reference path="../controllers.ts"/>
/// <reference path="../collabClientApp.ts"/>

"use strict";

collabClientApp.controller("ProjectListController",
  function ProjectListController($scope) {
    $scope.projects = projects;
});

collabClientApp.ts is the name of the file which does the routing. I get the following message:

Uncaught ReferenceError: collabClientApp is not defined

The reference part is correct, so collabClientApp should be found in the controller-file. Or do I miss something?

Help is very much appreciated.

1

1 Answer 1

1

You need to compile with the --out option to get a single file. OR include all files using script tags OR use a module loader like RequireJS

Sign up to request clarification or add additional context in comments.

1 Comment

Ah thanks. I must have overseen the tsc argument for generate one big file. Thanks for you help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.