AngularJs $scope

wylc123 1年前 ⋅ 484 阅读
<div ng-app="myApp" ng-controller="myCtrl">
    <input ng-model="name">
    <h1>{{greeting}}</h1>
    <button ng-click='sayHello()'>点我</button>    </div>
 <script>
var app = angular.module('myApp', []);app.controller('myCtrl', function($scope) {
    $scope.name = "Runoob";
    $scope.sayHello = function() {
        $scope.greeting = 'Hello ' + $scope.name + '!';    };});
</script>

 

更多内容请访问:IT源点

相关文章推荐

全部评论: 0

    我有话说: