Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • stephen 68 posts 109 karma points
    Oct 02, 2019 @ 12:19

    Back Office ng-repeat repeats itself

    I created a simple Back Office datatype with a js controller, resource,html, manifest and c# controller but the ng-repeat fires twice.


      <div ng-controller="My.custom02">
            <div ng-repeat="person in people" >
                    <p>First Name: {{person.fname}} {{people.length}}</p>

    js controller:

    custom02.GetAllData().then(function (response) {
       $scope.people =;

    js resource

    angular.module('umbraco.resources').factory('custom02', function ($http) {
    return {
        GetAllData: function () {
            return $http.get("backoffice/Dignity/BackOfficeApi/getName");


    The BackOfficeApi/getName just returns a simple string ("John")

    The contains the correct data ("John") and the same goes for $scope.people but the ng-repeat indicates the people.length is 4.

    One suggestion I have seen is that the angular library is being called multiple times but not sure if that is the case.

    I have created similar in previous Umbraco versions so wondering if it is something to do with V8.

  • Kevin Jump 1709 posts 10947 karma points MVP 4x c-trib
    Oct 02, 2019 @ 12:46
    Kevin Jump

    Hi Stephen,

    i think you are getting this result because your API controller is returning a string and not an array of strings.

    so when the angular gets "john" and you to a repeat it is looping through the characters, and that is what gives you the length 4

    if instead you API controller returns an array (even just of one name) the angular will get ["john"] and that is a single element, so should just show the single name.

  • stephen 68 posts 109 karma points
    Oct 02, 2019 @ 12:53

    Hi thanks. That makes sense. I'll check it out.

Please Sign in or register to post replies

Write your reply to: