Need some n00b Angular help

paperfist

Diamond Member
Nov 30, 2000
6,517
280
126
www.the-teh.com
I'm trying to get some code I found to work, not sure if I have it in the right components:

This is in: app.component.ts
Code:
angular.module("my-app", [])
.controller("myCtrl", function($scope) {
  $scope.someFunction = function() {
    $scope.date = new Date();
  }
})

This is in: app.component.html
Code:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body ng-app="my-app" ng-controller="myCtrl">
  <pre>current date: {{date | date: '<MM>
  <dd></dd>/yyyy'}}</pre>
  <pre>time: {{date | date: 'HH:mm:ss'}}</pre>
  <button ng-click="someFunction()">show date time</button>
</body>

I'm using MS Visual Studio Code and in app I'm getting: "contains emphasized items" error and in app.component.ts I'm getting "Untracked" error.

In the command line I'm getting this error: "error TS2304: Cannot find name 'angular'."

I was using this code to learn angular and so far I'm already stumped. Any help or tips would be appreciated!
 

paperfist

Diamond Member
Nov 30, 2000
6,517
280
126
www.the-teh.com
The error sounds like the library wasn't loaded. If you make a plnkr so people could look at it and edit it you'd get more replies. Also the version of angular that you're using.


Here's a simple setup for angularjs 1.5 https://embed.plnkr.co/O1sl0XZTeHlFVbZLHAWm/

Thanks! I actually forgot about this and figured out the problem is I was using Angular 5 and the code was written for Angukar Js