把控制器存储到外部文件
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>{{lastname}}</h1>
<input ng-model="llr">
<h1>{{llr}}</h1>
<h1>{{last}}</h1>
结合:{{fullName()}}
</div>
<!-- 把控制器存储到外部文件 -->
<script src="./controller.js"></script>
</body>
外部js控制器
var app = angular.module('myApp',[]);
app.controller('myCtrl',function($scope,$rootScope){
$scope.llr = 'lllll';
$scope.last = 'aaa';
$rootScope.lastname = 'Refs';
$scope.fullName = function () {
return $scope.llr +" " +$rootScope.lastname;
};
$scope.pirce = 9.99;
$scope.laa = 1;
$scope.names=[{name:'llr',age:12},{name:'page',age:11}]
})