我是新来的angularjs,我正在学习指令,我试图将值传递给指令,但是这个东西没有工作。将一个变量的值传递给angularjs指令
HTML
<genericsearch objectType="tei_org" organisationSearch="organisationSearchEvent"></genericsearch>
指令
directive('genericsearch', [function() {
return {
restrict: 'E',
replace: true,
scope: {
objectType : '=',
},
controller: ['$scope','$element','$rootScope','SearchOrg','MapOrgs','$routeParams','DelOrgs','GetTemplateGroups','FetchOrgs', function($scope,$element,$rootScope,SearchOrg,MapOrgs,$routeParams,DelOrgs,GetTemplateGroups,FetchOrgs){
$scope.getOrgs = function(objectType, event) {
if(event.keyCode != 13){
//$scope.Participants(data);
$scope.organisationSearchEvent(objectType);
}
}
$scope.organisationSearchEvent = function(filter,objectType){
SearchOrg().fetch({'filter':filter, 'searchType':objectType}).$promise.then(
function(value){
$scope.orgList = value.data;
},
function(err){
});
}
}],
templateUrl : TAPPLENT_CONFIG.HTML_ENDPOINT[0]+'home/search.html'
}
}])
到底什么是 “不工作”? – gefei
感谢您的回复,但事情是我需要传递tei_org到organizationsearchEvent eventhandler如何通过使用$范围做到这一点,我无法做到这一点。请帮我 – harrini
我觉得属性应该是html中的对象类型而不是objectType。这加上Rouby说的 – sirrocco