0

I am getting some value like "OPEN" or "CLOSE" from the function $scope.getPIRData, that I am storing in the $scope.pirstatus , I am trying to show that in the HTML Header tag<h1> {{pirstatus}}</h1> but its not showing anything in the button click while its working with the javascript document.getelementbyid.

 <!DOCTYPE html>
    <html ng-app="PIR_Detection">
    <head>
        <meta charset="utf-8" />
        <title>PIR Door Monitoring</title>
        <script>document.write('<base href="' + document.location + '" />');</script>
        <script data-require="[email protected]" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script>
    </head>
    <body ng-controller="myCtrl">
        <div class="col-sm-4 col-lg-offset-4" ng-controller="myCtrl">
            <select class="form-control" ng-model="sel_val" ng-change="getPIRData(sel_val.deveui)" ng-options="data.deveui for data in Customers">Select PIR Device</select>
        </div>
        <br />
        <span style="font-size:14px" id="pirstatus"></span>
        <h1> {{pirstatus}}</h1>
        <span ng-bind="pirstatus"></span> 
        <script>
            var app = angular.module('PIR_Detection', []);
            app.controller('myCtrl', function ($scope, $http, $window) {
                $scope.sel_val = 0;
                $scope.DefaultLabel = "Loading.....";
                var post = $http({
                    method: "get",
                    url: "../data.json",
                    dataType: 'json',
                    data: {},
                    headers: { "Content-Type": "application/json" }
                });
                post.success(function (data, status) {
                    $scope.Customers = data;
                });
                post.error(function (data, status) {
                });
                $scope.getPIRData = function (id) {
                    var url = "/PIRDetails/GetPIRStatus/" + id;
                    $http.get(url)
                        .then(function (response) {
                            $scope.myWelcome = response.data;
                            $scope.pirstatus = base64toHEX($scope.myWelcome.dataFrame);
                            document.getElementById("pirstatus").innerHTML = $scope.pirstatus;
                        });
                };
            });


        </script>

    </body>
    </html>

1 Answer 1

0

You can try with ng-bind attribute in AngularJS. In your code, below should work if you modify the h1 tag <h1 ng-bind="pirstatus"></h1> Please refer to this example - https://www.w3schools.com/angular/tryit.asp?filename=try_ng_ng-bind

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

2 Comments

its not showing anything to me , its just showing blank. i had mistake that i had mentioned ng-controller 2 times one in body and 1 in div. so it was not coming
Glad you found the issue.

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.