1、问题背景
ng-controller:该指令是用于AngularJS应用添加控制器
2、实现源码
<!DOCTYPE html> <html> <head> <Meta charset="UTF-8"> <title>AngularJS之ng-controller指令</title> <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> <script> var app = angular.module("youApp",[]); app.controller("haiCon",function($scope){ $scope.studentNo = "2016010101"; $scope.studentName = "张华"; }); </script> </head> <body> <div ng-app="youApp" ng-controller="haiCon"> <input type="text" ng-model="studentNo" /><br><br> <input type="text" ng-model="studentName" /><br><br> 学号:{{studentNo}}<br> 姓名:{{studentName}} </div> </body> </html>
3、实现结果
原文链接:https://www.f2er.com/angularjs/149081.html