i am trying to access the variable "k" from out side the $scope function
.controller('AboutCtrl', ['$scope','$http', function($scope,$http) {
var k ="";
$scope.search = function() {
// $scope.searchText will give the search terms
k = $scope.searchText;
console.log(k); //has something
};
console.log(k); // this is empty
k = $scope.searchText
this statement is bound to the block scope of function expression$scope.search
, hence it would not work on initial load.searchText
value before its definition. also it depends on why this flow is required in the app