简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <link href="/static/next/css/tryit.css?v=2017082407" rel="stylesheet"/> <div ng-app="" ng-controller="personController"> 名: <input type="text" ng-model="person.firstName"><br> 姓: <input type="text" ng-model="person.lastName"><br> <br> 姓名: {{fullName()}} </div> <footer>简单教程,简单编程<br/>Copyright © 简单教程 www.twle.cn</footer> <script> function personController($scope) { $scope.person = { firstName: "John", lastName: "Doe", }; $scope.fullName = function() { var x = $scope.person; return x.firstName + " " + x.lastName; } } </script> <script src="//www.runoob.com/try/angularjs/1.2.5/angular.min.js"></script>
运行结果: