Angularjs 自动添加新项-角度UI查询
我在一个网站上添加了一个“新故事”功能,供作者贡献作品。下面的功能允许创建故事并将其添加到作者的个人资料中,但不会自动将其添加到列表中(即我必须刷新浏览器才能使其正常工作。是否有人知道是否有办法做到这一点(我已尝试将状态改回“authorprofile”,但没有成功)Angularjs 自动添加新项-角度UI查询,angularjs,Angularjs,我在一个网站上添加了一个“新故事”功能,供作者贡献作品。下面的功能允许创建故事并将其添加到作者的个人资料中,但不会自动将其添加到列表中(即我必须刷新浏览器才能使其正常工作。是否有人知道是否有办法做到这一点(我已尝试将状态改回“authorprofile”,但没有成功) 假设故事列表存储在范围上的“故事”变量中: // auto-add new stories here $scope.stories.push(data); 在success函数中使用push方法将新故事添加到数组中 Stor
假设故事列表存储在范围上的“故事”变量中:
// auto-add new stories here
$scope.stories.push(data);
在success函数中使用push方法将新故事添加到数组中
Story.save(data, function(story) {
//Add stories to the array
$scope.stories.push(story);
Story.put(data, function(story){
console.log("story added");
})
// auto-add new stories here
$state.go('authorprofile');
})
谢谢fikkatra,我还没有完全理解它,但我会用$scope玩一玩
Story.save(data, function(story) {
//Add stories to the array
$scope.stories.push(story);
Story.put(data, function(story){
console.log("story added");
})
// auto-add new stories here
$state.go('authorprofile');
})