我正在使用Angular构建一个简单的网页注册表格,将数据存储在Parse中。
controller('AppCtrl', ['$scope', '$rootScope', function($scope, $rootScope) {
$rootScope.groupCreated = false;
$scope.signUp = function(form) {
var Group = Parse.Object.extend("AdminOrg");
var group = new Group();
group.set("groupName", form.name);
group.set("groupPassword", form.password);
group.save(null, {
success: function(data) {
$rootScope.groupCreated = true;
},
error: function(data, error) {
alert(error.message);
}
});
};
}]);
我正在使用$rootScope.groupCreated在我的HTML中,一旦成功函数被调用,隐藏注册表格并显示“小组创建成功”的消息。该值已经成功地更改为true,但是它没有改变HTML视图。我正在使用以下代码来隐藏和显示两个div:
ng-hide="$rootScope.groupCreated"
ng-show="$rootScope.groupCreated"
我在HTML中是否不正确地访问了$rootScope?
ng-hide="groupCreated"
。 - vp_arth