我有一个angular / rails应用程序,我目前有能力发布内容,但我似乎无法编写删除帖子所需的代码。
我的Github:https://github.com/JeremyLopez/ToDoList/tree/master/ToDoList
创建:(tasks.js
)
angular.module('toDoList')
.factory('tasks', [
'$http',
function($http){
var o = {
tasks: []
};
o.create = function(task) {
return $http.post('/tasks.json', task).success(function(data){
o.tasks.push(data);
});
};
但我怎么写一些非常相似的东西只删除帖子?我已经包含了我的github,因为我不确定哪个文件是相关的,但请关注app/controller/tasks_controller.rb
,javascripts/home/mainCtrl.js
,最重要的是javascripts/tasks/tasks.js
。
由于
答案 0 :(得分:0)
此功能有效!
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>some file</file>
<type>extension of your file </type>
<classifier>optional</classifier>
</artifact>
...
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
...我确实需要对o.destroy = function(task) {
return $http.delete('/tasks/' + task.id + '.json').success(function(data){
console.log("Task " + task.title + " has been deleted!")
});
};
进行更改:
app/controllers/tasks_controller.rb