Note that there are some explanatory texts on larger screens.

plurals
  1. POng repeat dosn't update itself after inserting new item using dialog
    primarykey
    data
    text
    <p>I am just a beginner with angularJs , and i am trying to do CRUD Operations using $http and asp.net MVC :-</p> <ol> <li><p>I am using ng-repeat to display list of "Terms" . </p></li> <li><p>I have a button to display a dialog ,which in turn will be used to inserting new "Term". </p></li> <li>ng-repeat works well and the dialog also displayed and i can insert new item successfully.</li> </ol> <p>the problem is :- - after inserting new term and closing the dialog , ng-repeat doesn't updating . and this the code i am using :</p> <pre><code>var glossayApp = angular.module("glossaryApp", ['ui.bootstrap.dialog']); var ctrl = glossayApp.controller("termController", function ($scope, $http, $route, $dialog, $window) { $scope.terms = []; $scope.init = function () { $http.get("/Home/List").success(function (data) { $scope.terms = data; }); } $scope.add = function () { $scope.opts = { backdrop: true, keyboard: true, backdropClick: true, templateUrl: '/Home/Add', controller: 'dialogController' }; var d = $dialog.dialog($scope.opts); d.open().then(function (term) { if (term) { $http.post('/Home/Add/', { Name: term.name, Definition: term.definition }).success(function () { $scope.init(); }); } }); } }); glossayApp.config(function ($routeProvider) { $routeProvider.when('/', { controller: 'termController', templateUrl: '/Home/list' }).when('/Details:id', { controller: 'termController', templateUrl: '/Home/details' }).otherwise({ redirectTo: '/' }); }); var dialogController = glossayApp.controller('dialogController', function ($scope, dialog) { $scope.save = function (term) { dialog.close(term); } $scope.close = function () { dialog.close(); } }); </code></pre> <p>and this the HTML I am using in ngrepeat :-</p> <pre><code>&lt;table border="0" cellpadding="0" cellspacing="0" ng-init="init();"&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt; Term &lt;/td&gt; &lt;td&gt; Definition &lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tr ng-repeat="term in terms"&gt; &lt;td&gt; {{term.Name}} &lt;/td&gt; &lt;td&gt; {{term.Definition}} &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;input type="button" name="Add" value="Add New Term" ng-click="add();" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload