【发布时间】:2013-04-08 10:48:28
【问题描述】:
有没有办法为 angularjs 序列化函数?
我的帖子现在看起来像这样。
$scope.signup_submit = function () {
var formData = {
username: $scope.username,
full_name: $scope.full_name,
email: $scope.email,
password: $scope.password,
confirm_password: $scope.confirm_password
}
$http({
method: "POST",
url: '/signup',
data: formData,
}).success(function (data) {
if (data.status == 'success') {
alert('all okay');
} else {
alert(data.msg)
}
});
}
【问题讨论】:
-
你试过了吗:$element.serialize()?
-
是的,它返回未定义的函数序列化
-
我认为他的意思是 $(element).serialize();你当然需要有 JQuery 才能做到这一点。
-
嗯,我认为 jquery 不能很好地使用 angular 看起来是个错误,我会尝试,谢谢
-
事实上,您不应该将 Angular 元素包装在 $ 中,因为如果 jQuery 存在,它会被默认包装。如果不存在 jQuery,则 Angular 使用小版本,the jqLite。
标签: javascript serialization angularjs