加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS加载完成之后触发事件

发布时间:2020-12-17 10:29:40 所属栏目:安全 来源:网络整理
导读:@{ Layout = null;}!DOCTYPE htmlhtml ng-app="my_app"head meta name="viewport" content="width=device-width" / titleIndex/title script src="~/Scripts/jquery-1.10.2.min.js"/script script src="~/Scripts/angular.min.js"/script script type="text/
@{
    Layout = null;
}
<!DOCTYPE html>
<html ng-app="my_app">
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/angular.min.js"></script>
    <script type="text/javascript">
        var app = angular.module("my_app",[]);
        app.controller('my_controller',function ($scope) {
            $scope.students = [
                    { id: 1,name: '张一' },{ id: 2,name: '李二' },{ id: 3,name: '王三' },{ id: 4,name: '马四' },{ id: 5,name: '鬼五' }
            ];
            $scope.getStudent = function (id) {
                alert(id);
            }
        });
        app.run(function ($timeout) {//等待AngularJS加载完成之后触发事件
            var a = $timeout(function () {
                alert($('table tr').length);
            },1000);
        });
    </script>
</head>
<body ng-controller="my_controller">
    <table>
        <tr>
            <th>id</th>
            <th>name</th>
        </tr>
        <tr ng-repeat="item in students">
            <td>{{item.id}}</td>
            <td><a href="#" ng-click="getStudent(item.id);">{{item.name}}</a></td>
        </tr>
    </table>
</body>
</html>  

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读