The HTML code looks like this:
1 <! DOCTYPE html>
2
The JavaScript code looks like this:
1 var ngapp = angular.module (' myApp ', []);
2 ngapp.controller (' Mycontroller ', function ($scope, $http) {
3 $scope. msg = ' Hello, angular. ';
4 $scope. GetData = function () {
5 return ' qubernet ';
6 }
7 });
8
9 onload = function () { document.getElementById (' lbtntest '). onclick = function () {
11< c19/>//through controller to get angular application var appelement = Document.queryselector (' [Ng-controller=mycontroller ]'); get $scope variable var $scope = angular.element (appelement). scope (); Call the MSG variable and change the value of MSG $scope. msg = ' 123456 ';
The value of MSG is changed on the///last line, and if you want to sync to the angular controller, you need to call the $apply () method to $scope. $apply (); the GetData () method Console.log ($scope. GetData ())
in the//Call controller. }
The effect is shown in the following image before clicking the "Call" button:
After clicking on the "Call" button, the effect is shown in the following image: