0

I have problem pertaining getting string to my controller in asp.net mvc controller. im totally new in angular js with asp.net mvc. can any one help me how to solve the problem. thanks in advance

my controller in asp

using MyProject.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyProject.Controllers
{
    public class AngularController : Controller
    {
        //
        // GET: /Angular/

        public ActionResult AngularForm()
        {
            return View();
        }


        public JsonResult AjaxMethod()
        {
            string name = "GEORGE";
            return Json(name, JsonRequestBehavior.AllowGet);
        }

    }
}

my script in angular js.

/// <reference path="angular.min.js" />

var myapp = angular.module('myApp', []);

myapp.controller('myController', function ($scope, $http) {

    $http.get("/angular/")

    .then(function (response) {
        $scope.username = response.data;
    });
});

my form in html

@{
    ViewBag.Title = "AngularForm";
}

<h2>AngularForm</h2>



<div data-ng-app="myApp" data-ng-controller="myController" >

    <ul>
    <li data-ng-repeat="customer in username">
       {{customer.username}}
    </li>
  </ul>

</div>



<script src="~/Scripts/myScript.js"></script>
FAISAL
  • 33,618
  • 10
  • 97
  • 105
  • 1
    So what exactly is the problem? – Anup Sharma Aug 05 '17 at 06:54
  • in my console it says. angular.js:14642 Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: customer in username, Duplicate key: string: , Duplicate value: – Jobert Jay Jaducana Aug 05 '17 at 06:55
  • check this answer https://stackoverflow.com/a/17246507/3785440 – Anup Sharma Aug 05 '17 at 07:04
  • Possible duplicate of [Angular ng-repeat Error "Duplicates in a repeater are not allowed."](https://stackoverflow.com/questions/16296670/angular-ng-repeat-error-duplicates-in-a-repeater-are-not-allowed) – Brian Aug 05 '17 at 19:05

0 Answers0