का उपयोग कर बाहरी फ़ाइल से जेसन डेटा का उपयोग कैसे करूं मैं एक एप्लीकेशन विकसित कर रहा हूं। उस में मैंमैं कोणीय जेएस आराम सेवा
बाहरी फ़ाइल $ http.get() विधि का उपयोग कर जेसन डेटा पुनर्प्राप्त कर रहा हूं, यह ठीक काम करता है। अब मैं कोणीय
आराम सेवाओं का उपयोग करने की कोशिश कर रहा हूं। यह फ़िल्टर में ठीक काम कर रहा है, लेकिन जब मैं इसे नियंत्रक में उपयोग करता हूं तो यह
अपरिभाषित प्रदर्शित करता है।
//Service.js File
angular.module('calenderServices', ['ngResource']).
factory('Events', function($resource){
return $resource('/EventCalender/:File.json', {}, {
query: {method:'GET', params:{File:'events'}, isArray:true}
});
});
//This is my app Module
angular.module('calender', ['eventFilters','highlight','event','calenderServices']).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('', {templateUrl: 'template.html', controller: MonthCtrl}).
otherwise({redirectTo: '/invalid'});
}]);
//This is my filter.js
angular.module('eventFilters', ['calenderServices']).filter('compare', function(Events) {
var events=Events.query();
alert(events[0].name); //it is displaying the name "Milestone1" });
//This is my controller.
function MonthCtrl($scope, Events){
var events=Events.query();
alert(events[0].name); //it is displaying undefined
}
//whenever i try to use the variable 'events' in controller, it is displaying undefined or null. But in filter it is working fine.
मैं इस कोशिश की, यह काम नहीं कर रहा था। मैंने अभी '$ scope.events' नाम '$ scope.eve' नाम बदल दिया है, यह अब काम कर रहा है। बहुत बहुत धन्यवाद। –