angular.module('finalApp').controller('GetAgentDetailsCtrl', function ($scope,$rootScope){
var vm=this;
vm.url='api/agent/getAgentDetails';
});
'use strict';
angular.module('finalApp').directive('homeHeader',['HttpService',function(HttpService){
return{
restrict:'E',
templateUrl:'views/directives/header/header.html',
controller: 'GetAgentDetailsCtrl',
controllerAs: 'GetAgentDetlCtrl',
link: function ($scope) {
HttpService.get(GetAgentDetlCtrl.url).success(function (data) {
$scope.GetAgentDetlCtrl.defaultData = data;
console.log($scope.GetAgentDetlCtrl.defaultData);
});
}
};
}]);
<header ng-controller="GetAgentDetlCtrl">
{{GetAgentDetlCtrl.data}}
</header>
<main>
<home-header></home-header>
</main>
答案 0 :(得分:0)
angular.module('finalApp').controller('GetAgentDetailsCtrl', function ($scope,$rootScope){
var vm=this;
vm.url='api/agent/getAgentDetails';
});
'use strict';
angular.module('finalApp').directive('homeHeader',['HttpService',function(HttpService){
return{
restrict:'E',
templateUrl:'views/directives/header/header.html',
controller: 'GetAgentDetailsCtrl',
controllerAs: 'GetAgentDetlCtrl',
scope: {
url : '='
}
link: function ($scope) {
HttpService.get($scope.url).success(function (data) {
$scope.GetAgentDetlCtrl.defaultData = data;
console.log($scope.GetAgentDetlCtrl.defaultData);
});
}
};
}]);
<header ng-controller="GetAgentDetlCtrl">
{{GetAgentDetlCtrl.data}}
</header>
<main>
<home-header url="http://yoursite.blah"></home-header>
</main>