<section ng-app="app" ng-controller="ctrl">
<div id="output">{{ foo }}</div>
<button ng-click="myFun()">Click me</button>
</section>
var app = angular.module("app", []);
app.controller('ctrl', function($scope, $http){
$scope.bar = 123;
$scope.myFun = function(){
$http.get('template.html').then(function(response){
$scope.foo = response.data;
});
};
});
//template
<h1>{{ bar }}</h1>
I'm new in angularjs
I try to create a ng-click and get a template data into page like ajax
I try to use variable inside of template
anyone know how to pass variable to template in angularjs?