Angular js Curly braces doesn't show value in html

Hi, I tried a lot of articles and answers from different questions, but no luck, I use an empty ionic project and it works on my browser with ionic.serve, there are also no errors.

{{truck}} displayed in my application, and not in the "Truck Value" value and {{truck}} not displayed constantly, it blinks as soon as I update the browser.

 html <body ng-app="starter"> <div ng-controller="Ctrl"> <h2>hey {{truck}}</h2> </div> </body> js var example = angular.module('starter', ['ionic', 'ngCordova']) ... example.controller("Ctrl", function() { var truck = "Truck Value"; }); 
+5
source share
5 answers
 example.controller("Ctrl", function($scope) { $scope.truck = "Truck Value"; }); 
+2
source

you need to pass $ scope as a parameter like this

 example.controller("Ctrl", function($scope) { ... } 

and assign your data to the scope inside this function, for example

 $scope.truck = "Truck Value"; 
+2
source

Pass $ scope as a parameter, and then try:

 var example = angular.module('starter', ['ionic', 'ngCordova']) ... example.controller("Ctrl", function($script) { $scope.truck = "Truck Value"; }); 
+1
source
 example.controller("Ctrl", function($scope) { $scope.truck = "Truck Value"; }); 
0
source

Use vm rather than $ scope in a future version of angular, it will be removed according to many discussions, so do a vm practice, not $ scope

  (function () { 'use strict'; var example = angular.module('starter', ['ionic', 'ngCordova']) var controllerId = 'Ctrl'; example.controller(controllerId,[Ctrl]); function Ctrl() { var vm = this; vm.truck="Truck Value"; } })(); in html <body ng-app="starter"> <div ng-controller="Ctrl"> <h2>hey {{vm.truck}}</h2> </div> </body> 
0
source

All Articles