Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 不显示ng标记输入自动完成_Json_Angularjs_Autocomplete_Ng Tags Input - Fatal编程技术网

Json 不显示ng标记输入自动完成

Json 不显示ng标记输入自动完成,json,angularjs,autocomplete,ng-tags-input,Json,Angularjs,Autocomplete,Ng Tags Input,我尝试使用ng标记输入,并通过api控制器.NETMVC6返回Json列表。我的列表是用json创建的,但当尝试用自动完成来显示这个列表时,并没有任何效果。我的自动完成列表没有显示,我在chrome控制台中没有错误 这是我列表中的一个对象: [{ "ShopID":1, "CompanyID":1, "RegionID":1, "Name":"Les Pieux", "Town":"Les Pieux", "Address":null, "ZipCode":null,

我尝试使用ng标记输入,并通过api控制器.NETMVC6返回Json列表。我的列表是用json创建的,但当尝试用自动完成来显示这个列表时,并没有任何效果。我的自动完成列表没有显示,我在chrome控制台中没有错误

这是我列表中的一个对象:

[{
  "ShopID":1,
  "CompanyID":1,
  "RegionID":1,
  "Name":"Les Pieux",
  "Town":"Les Pieux",
  "Address":null,
  "ZipCode":null,
  "CreateDate":"2006-01-01T00:00:00",
  "ModificationDate":"2006-09-29T00:00:00",
  "LastModificationUserID":1,
  "PhoneNumber":null,
  "Fax":null,
  "Email":null,
  "CEmployeeShop":null
 }]
这是我在控制器中的方法:

 $scope.tokenShops = [];
 $scope.loadJsonShops = function(query)
    {
        //$scope.shops contains my list of shops in json format.
        return $scope.shops;
    }
以及Html中的标记:

<div ng-controller="EmployeesCtrl">
            <tags-input ng-model="tokenShops"
                        display-property="Name"
                        Placeholder="Ajouter un magasin"
                        add-from-autocomplete-only="true">
                <auto-complete resource="loadJsonShops($query)"></auto-complete>
            </tags-input>
        </div>
angularjs EmployeeCtrl:

$scope.$on("getListShops", function (event, args) {
    $scope.shops = args.list;
    $scope.selectShop = args.list[0];
})
但我不认为我的问题来自我的json列表。
我希望有人能帮助我。祝您度过愉快的一天。

自动完成
需要至少具有一个名为“text”属性的对象数组(就像
标记输入
),如果您没有使用模板进行
自动完成
标记输入
。您还需要为
自动完成
筛选结果,以便正常工作。另请参见此图。

我使用指令解决问题:

angular.module('TagsDirective', ['myResources', 'resourcesManagerGet', 'translateI18n'])
.directive('tags', function ($http, $q) {
    return {
        restrict: 'E',//restraint pour les éléments du dom
        template: '<tags-input ng-model="SShops" key-property="ShopID" display-property="Name" placeholder="{{\'AddShop\' | i18n}}" add-from-autocomplete-only="true"><auto-complete source="loadTags($query)"></auto-complete></tags-input>',
        scope: false,

        link: function (scope, el) {
            scope.loadTags = function (query) {
                var deferred = $q.defer();
                var reqGetShops = $http({ url: 'api/Shops/GetListShopFiltered', params: { 'query': query } });
                reqGetShops.success(function (data) {
                    deferred.resolve(data);
                });
                return deferred.promise;
            }
        }
    }
});
angular.module('TagsDirective',['myResources','resourcesmanagetarget','translateI18n']))
.directive('tags',function($http,$q){
返回{
限制:'E',//限制
template:'并查看使用自定义对象输入的标记。

angular.module('TagsDirective',['myResources','ResourcesManager','translateI18n'])
angular.module('TagsDirective', ['myResources', 'resourcesManagerGet', 'translateI18n'])
.directive('tags', function ($http, $q) {
    return {
        restrict: 'E',//restraint pour les éléments du dom
        template: '<tags-input ng-model="SShops" key-property="ShopID" display-property="Name" placeholder="{{\'AddShop\' | i18n}}" add-from-autocomplete-only="true"><auto-complete source="loadTags($query)"></auto-complete></tags-input>',
        scope: false,

        link: function (scope, el) {
            scope.loadTags = function (query) {
                var deferred = $q.defer();
                var reqGetShops = $http({ url: 'api/Shops/GetListShopFiltered', params: { 'query': query } });
                reqGetShops.success(function (data) {
                    deferred.resolve(data);
                });
                return deferred.promise;
            }
        }
    }
.directive('tags',function($http,$q){ 返回{ 限制:'E',//限制 模板:“”, 范围:假, 链接:功能(范围,el){ scope.loadTags=函数(查询){ var deferred=$q.deferred(); var reqGetShops=$http({url:'api/Shops/GetListShopFiltered',参数:{'query':query}}); reqGetShops.成功(功能(数据){ 延迟。解析(数据); }); 回报。承诺; } } }
填充$scope.shops的代码在哪里?
angular.module('TagsDirective', ['myResources', 'resourcesManagerGet', 'translateI18n'])
.directive('tags', function ($http, $q) {
    return {
        restrict: 'E',//restraint pour les éléments du dom
        template: '<tags-input ng-model="SShops" key-property="ShopID" display-property="Name" placeholder="{{\'AddShop\' | i18n}}" add-from-autocomplete-only="true"><auto-complete source="loadTags($query)"></auto-complete></tags-input>',
        scope: false,

        link: function (scope, el) {
            scope.loadTags = function (query) {
                var deferred = $q.defer();
                var reqGetShops = $http({ url: 'api/Shops/GetListShopFiltered', params: { 'query': query } });
                reqGetShops.success(function (data) {
                    deferred.resolve(data);
                });
                return deferred.promise;
            }
        }
    }
});
<tags></tags>
angular.module('TagsDirective', ['myResources', 'resourcesManagerGet', 'translateI18n'])
.directive('tags', function ($http, $q) {
    return {
        restrict: 'E',//restraint pour les éléments du dom
        template: '<tags-input ng-model="SShops" key-property="ShopID" display-property="Name" placeholder="{{\'AddShop\' | i18n}}" add-from-autocomplete-only="true"><auto-complete source="loadTags($query)"></auto-complete></tags-input>',
        scope: false,

        link: function (scope, el) {
            scope.loadTags = function (query) {
                var deferred = $q.defer();
                var reqGetShops = $http({ url: 'api/Shops/GetListShopFiltered', params: { 'query': query } });
                reqGetShops.success(function (data) {
                    deferred.resolve(data);
                });
                return deferred.promise;
            }
        }
    }