AngularJS Elastic UI依赖注入

时间:2015-04-01 11:38:07

标签: angularjs

我对Angular中的依赖注入有疑问。

我正在使用ElasticUI: https://github.com/YousefED/ElasticUI

需要在标记内设置索引名称。

<body ng-app="tutorial" eui-index="'INDEX_NAME'">

是否可以将INDEX_NAME设置为“外部”?

angular.module('tutorial', ['elasticui']). ???

我对Angular了解不多。如果这是一个愚蠢的问题,我很抱歉...

感谢您的帮助!

2 个答案:

答案 0 :(得分:1)

您需要在&#34; IndexVM&#34;中更改索引名称。实例然后刷新界面。以下是代码:

.controller('MyController', function($scope) {
    $scope.IndexName="abc";
    $scope.changeIndexName(field);   
    $scope.indexVM.index=$scope.IndexName; 
    $scope.indexVM.refresh(false);
});

答案 1 :(得分:0)

就像将值传递给指令一样。在您的控制器中:

.controller('MyController', function($scope) {
    $scope.indexName = "asdsd";
})

在HTML中:

<body ng-app="tutorial" ng-controller="MyController" eui-index="indexName">