• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need some n00b Angular help

paperfist

Diamond Member
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!
 
Back
Top