Javascript 平均堆栈-ng在ng内单击重复不使用数据库
//app.js var blogApp=angular.module'blogApp',[]//角度模块设置,与index.html中的ng应用程序匹配 控制器'BlogController',函数$scope,$http{//如果要使用http注入依赖性,则必须添加$http $scope.createPost=createPost;//从index.html绑定中获取createPost $scope.deletePost=deletePost;//从index.html映射deletePost 函数init{//将站点第一次加载时发生的所有事情都放在init函数中,这是一个很好的实践 获取所有帖子; } init;//调用init函数以显示所有数据库日志 函数getAllPosts{//检索最新的博客帖子 $http.get/api/blogpost.successfunction posts{//如果成功,将posts发送回客户端 $scope.posts=posts;//使用$scope发送回客户端 }; } 函数createPostpost{//从index.html中的ng模型获取post对象 console.logpost;//在html站点的控制台日志中显示post信息 $http.post/api/blogpost,post.successgetAllPosts;//将“post”数据推送到api/blogpost url,在发布新帖子时也调用函数getAllPosts console.logposted; } 函数deletePostId{//deletePost与ng click的索引文件中的名称相同 console.logposted; $http.delete/api/blogpost/+postId.successgetAllPosts;//只删除一个具有特定id的帖子,如果没有+postId,则会删除所有帖子 } }; 标题 博客 邮递 {{post.title} {{post.posted}} {{post.body} {{posts}}Javascript 平均堆栈-ng在ng内单击重复不使用数据库,javascript,angularjs,express,mean-stack,Javascript,Angularjs,Express,Mean Stack,//app.js var blogApp=angular.module'blogApp',[]//角度模块设置,与index.html中的ng应用程序匹配 控制器'BlogController',函数$scope,$http{//如果要使用http注入依赖性,则必须添加$http $scope.createPost=createPost;//从index.html绑定中获取createPost $scope.deletePost=deletePost;//从index.html映射deleteP
由于拼写错误,它无法正常工作:
ng-click="deletPost(post._id)"
到
在您的描述中称之为deletePost,但在您的代码中称之为deletpost。_id.Typo?谢谢您是的,它是Typo,一定在这个屏幕上看得太久了。非常感谢您,不敢相信我没有看到。至少现在我是一个专家在ng中点击ng重复我刚才做的所有研究哈哈。哈哈真的。大有可为
ng-click="deletePost(post._id)"