发表于: 2016-06-24 00:20:51
1 2560
今天完成的事情:刷了网上的教程和《用angularjs开发下一代web》,已经知道修改和删除怎么写啦
明天完成的事情:写完task5
遇到的问题:想在no-repeat生成的表格中获取,通过ng-click获取id,然而一直报错。。。
<tr ng-repeat = "item in names" ng-click = "killyou(item)">
<td>{{item.id}}</td>
<td>{{item.name}}</td>
<td>{{item.qq}}</td>
<td>{{item.type}}</td>
<td>{{item.school}}</td>
<td>{{item.talent}}</td>
<td>{{item.jointime}}</td>
<td>{{item.wish}}</td>
</tr>
// 查看
$scope.killyou = function (item) {
var person = $scope.item;
console.log(person.id);
}
。。。怎么写啦,好慌啊啊啊啊
收获:angularjs的四个特性,依赖注入,双向绑定,模块化,mvc。
m
控制数据的部分
v
html的那一块
c
app.controller('customersCtrl', function($scope, $http) {
//新建学员
$scope.newone = {};
$http.get("/a/students/")
.success(function(response) {$scope.names = response.data;});
//查看学员列表
$scope.go = function () {
$http.get("/a/students/")
.success(function(response) {$scope.names = response.data;});
}
//添加
$scope.godead = function (newone) {
var newone = $.param($scope.newone);
console.log(typeof $scope.newone.name);
$http({
method:'post',
url:"/a/student",
data:newone,
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
}
}).success(function () {
alert(newone.name);
alert("ok");
});
}
// 查看
$scope.killyou = function (item) {
var person = $scope.item;
console.log(person.id);
}
});
模块化
var app = angular.module('myApp', []);
控制器啦,数据啦,指令啦都在module里面
依赖注入
function($scope, $http)
双向绑定就不说了,好烦啊。angularjs
评论