您的位置:首页 > Web前端 > AngularJS

angularjs,js调用angularjs中的方法和参数

2014-12-16 16:36 162 查看
@{
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) {
window.scope = $scope;
var vm = $scope.vm = {};
vm.students = [
{ id: 1, name: '张一' },
{ id: 2, name: '李二' },
{ id: 3, name: '王三' },
{ id: 4, name: '马四' },
{ id: 5, name: '鬼五' }
];
$scope.getStudentLength = function (items) {
alert(items.length);
}
});
</script>
<script type="text/javascript">
$(function () {
var $scope = window.scope;
var vm = $scope.vm;
$scope.getStudentLength(vm.students);
});
</script>
</head>
<body ng-controller="my_controller">
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  angularjs js