1

I've one global variable called rowTag as array of Tag[] entity in main.ts file.

I've one angular controller called TagMeController.ts file

Here is a constructor of TagMeController

constructor($scope, $rootScope) {
            $scope.CloseMe = this.CloseMe;
            $scope.rowTags = rowTag;//rowTag global variable
            $scope.colTags = colTag;//colTag global variable
            $scope.UpdateMe = this.UpdateMe;
        }

So, when I update rowTag object from the same controller, it update respective element on UI but when I update same object from some another .ts(main.ts) file things are not being reflected.

Any idea on how to make that variable observable ?

1 Answer 1

3

Any idea on how to make that variable observable

Create an angular service to contain that piece of information,

class Tags {
    rowTags = [] 
    colTags = []
}

and then use that service :

constructor($scope, $rootScope, tags: Tags) {
    $scope.CloseMe = this.CloseMe;
    $scope.tags = tags; // Tags service containing `rowTag` and `colTag`
    $scope.UpdateMe = this.UpdateMe;
}

Here is a video on creating an angular service using TypeScript : https://www.youtube.com/watch?v=Yis8m3BdnEM

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

1 Comment

Could you please add more details on this ?

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.