AngularJS Introduction
AngularJS is a JavaScript framework. It can be added to HTML pages via the <script> tag.
AngularJS extends HTML through directives and binds data to HTML through expressions.
The following is an example code for Angular.js to implement digital conversion Chinese characters through this article. The specific code is as follows:
// 1. Implement the input and digital output corresponding Chinese characters, and requires the use of angularjs. The $watch function is not allowed, and the for loop is not allowed. Tip: ng-change instruction <div ng-app="myApp" ng-controller="changeCtrl"> // Define an app instruction Define a controller instruction to add controllers to your application. In the controller, you can write code, make functions and variables, and use scope objects to access. Number: <input ng-model="number" ng-change="changeFunc(number)"> // The ng-model directive binds HTML form elements into the scope variable. If there is no variable in scope, it will be created. The ng-change event triggers <h1> every time the value changes, you enter: {{result}}</h1> // The value bound to ng-model data</div><script>var app = angular.module('myApp', []); // Create a new module, note that the new module needs to introduce app.controller('changeCtrl', function($scope) in app.js { // Create a controller method for html to use $scope.number = ""; // Here is the value that appears in the input box $scope.result = ""; // The result is the value var that appears in h1 array=["zero","one","two","three","four","five","six","seven","eight","nine","ten"];$scope.changeFunc=function(number){ // Define an ng-change method, and start when the value in input changes (input a value in input, the method changes once) console.log("number=",number);if(number != ''){ $scope.result = "";var atr=number.replace(/(.)(?=[^$])/g,"$1,").split(",");//The first type// Add ' to each number in intercepted form', 'split turns the string into an array atr.forEach(function(e){ // Loop array atr$scope.result += array[e];});/*for(var a in number){ // The second console.log("number[a]=",number[a]);var i = parseInt(number[a]);$scope.result += array[i];}*/}});</script>The above is the example code for Angular.js to implement digital conversion of Chinese characters introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!