javascript - How to get a value from controller.js file to html file in angularjs -


i have stored value in scope on controller.js.how scope value in html file.

controller.js

myappcont.controller('listvalue',['$scope','$rootscope','$http', function($scope,$rootscope,$http){        city=$scope.val; }]); 

html

 <div class="col-md-10" ng-controller="listvalue">  <table class="table table-bordered table-style" id="statustable">   <thead>    <tr>     <th>values</th>    </tr>    </thead>    <tbody class="align-center">     <tr>     <td>{{city}}</td>     </tr>     </tbody>     </table>     </div> 

you need have $scope variable inside controller, other way

myappcont.controller('listvalue',['$scope','$rootscope','$http', function($scope,$rootscope,$http){       $scope.city=val; }]); 

then evaluated , shown in view

 <td>{{city}}</td> 

working sample


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -