Hi Sander, so when do we put ng-controller in the template and when don't have to? Im confused, Ive just started learning Angular.
On Wednesday, November 25, 2015 at 3:02:46 AM UTC-5, [email protected] wrote: > > > <https://lh3.googleusercontent.com/-S-j0T6nkx9E/VlVrCgln36I/AAAAAAAAAA0/aT2-BAvI6fw/s1600/angu1.jpg> > > I am a Beginner to angularjs. > I have a button on my _home.htm in a list of items. <button > ng-click="bon_loeschen(post.id)">Löschen</button> > This works, but in the networkanalyses i see that the request was executet > two times. > Another question. After deleting i want to reload the content from > database automatically. with $scope.bons_laden > How can i accomplish this? > Thanks in advance. > > angular.module('bons', ['ui.router','templates','ui.bootstrap']) > .config([ > '$stateProvider', > '$urlRouterProvider', > function($stateProvider, $urlRouterProvider) { > > $stateProvider > .state('home', { > url: '/home', > templateUrl: '_home.html', > controller: 'MainCtrl' > }).state('eingabe', { > url: '/eingabe', > templateUrl: '_bon_form.html', > controller: 'BonNeu' > }); > $urlRouterProvider.otherwise('home'); > }]) > > .controller('MainCtrl', [ > '$scope','$http','$timeout', > function($scope,$http,$timeout){ > $scope.bon_loeschen = function(nr){ > $http({ > url : 'bons/' + nr, > method : 'DELETE', > data: {id: nr}, > headers: {"Content-Type": "application/json;charset=utf-8"} > }).then(function(res){ > alert("gelöscht"); > }, function(error){ > alert(error); > }); > }; > $scope.bons_laden = function(){ > $http({ > method : 'GET', > url : 'bons.json' > }).success(function(data){ > $scope.posts = data; > }); > }; > > }]) > > > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
