angular with typescript error, cannot find name angular

Zakk

I done all the settings including adding typescript compiler in webstorm, installing tsd with npm, and all other stuff.

I still get error 'Cannot find name Angular'

tsd.json

{

  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  "path": "typings",
  "bundle": "typings/tsd.d.ts",
  "installed": {
    "angularjs/angular.d.ts": {
      "commit": "70a693ec17c7ae4b9b7c1fa6c399ac3e82e3843e"
    },
    "jquery/jquery.d.ts": {
      "commit": "70a693ec17c7ae4b9b7c1fa6c399ac3e82e3843e"
    }
  }
}

sorting.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
{{$ctrl.mytest}}
</body>
</html>

sorting.ts

var app = angular.module('myApp', []);
app.component('sorting', {
    templateUrl: 'modules/sorting/sorting.html',
    controller: SortingClass
});

 class SortingClass {

    public mytest: string = 'abcd';

}

index.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="UTF-8">
    <title> Facility</title>
    <script type="text/javascript" src="bower_components/angular/angular.js"></script>
    <script src="modules/sorting/sorting.js" type="text/javascript"></script>
</head>
<body>
</body>
g.005

My friend, you have lot of syntax errors. Please have a look at the basics of angular js. For now, try this code. This should work:

Index.html

<!DOCTYPE html>
<html ng-app="myApp">
<head lang="en">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta charset="UTF-8">
    <title> Facility</title>
    <script type="text/javascript" src="bower_components/angular/angular.js"></script>
    <script src="modules/sorting/sorting.js" type="text/javascript"></script>
</head>
<body ng-controller="sorting as ctrl">
   <div> {{ctrl.mytest}} </div>
</body>
</html>

Sorting.ts

module xyz {
var angular: any;
var app = angular.module('myApp', []);
app.controller('sorting', SortingClass);

 public class SortingClass {
   public mytest: string = 'abcd';
 }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular and Typescript: Can't find names - Error: cannot find name

TypeScript error in Angular2 code: Cannot find name 'module'

Cannot find name error angular

Getting Error - Cannot find name 'angular'

Cannot find name of 'of'' Angular

Cannot find name in JavaScript file in Angular 4 TypeScript

Typescript cannot find name error

Cannot find namespace error for model in Angular2/TypeScript

Angular Cannot Find Name Buffer

Angular 7: 'Cannot find name ' '

Angular8 - error TS2304: Cannot find name

What causes the "Cannot find name" error in this Angular 11 application?

Angular material stepper: Error: Cannot find control with name: 'formArray'

error TS2304: Cannot find name 'trim' in Angular 5

After update webpack and Angular receives an error Cannot find name 'setImmediate'

Compile error - Cannot find name 'Map' & more - Angular 2

Angular 4 Error: Cannot find control with unspecified name attribute

Angular 2+ Error: Cannot find name 'gapi'

Angular error TS2304: Cannot find name 'config'

Angular 6: ERROR Error: Cannot find control with unspecified name attribute with angular material and reactive forms

Typescript error - Cannot find name 'require'

typescript error - cannot find name 'process'

Typescript Error: Cannot find name 'cordova'

Angular2 TypeScript - error TS2307: Cannot find module 'angular2/forms'

Cannot find name 'headers'. in angular 2

Angular service testing: Cannot find name 'asyncData'

Cannot find name 'Http' in Angular 10

Angular 2 Cannot find name SimpleChanges

Angular Cannot find control with unspecified name attribute