मैं मार्गों के मॉडल को कैसे बनाए रखूं। उदाहरण के लिए मेरे पास होम पेज पर लोड प्रोफाइल की एक सूची है। होम पेज में अधिक प्रोफाइल लोड करने के लिए "लोड लोड" एक्शन भी शामिल है, मूल रूप से मॉडल को डेटा को दबाकर। किसी विशिष्ट प्रोफ़ाइल पर क्लिक करने पर, उस प्रोफ़ाइल के लिए विवरण-दृश्य मार्गों के माध्यम से सक्रिय किया जाता है। विवरण दृश्य में एक बैक बटन होता है जो उपयोगकर्ता को होम पेज पर रीडायरेक्ट करता है। "लोड लोड" कार्रवाई से लोड किए गए होम पेज डेटा (प्रोफाइल) पर वापस जाने पर कार्रवाई खो जाती है। मैं "लोड अधिक" के साथ मॉडल बनाए रखने की जरूरत डेटाangularjs मार्गों में स्कोप चर बनाए रखता है
prepended नीचे कोड का इस्तेमाल किया
/* Controllers */
var profileControllers = angular.module('profileControllers', ['profileServices'])
profileControllers.controller('profileListCtrl', ['$scope','$location', 'Profile','$http',
function($scope,$location, Profile,$http) {
$scope.Profiles = Profile.query(function(){
if($scope.Profiles.length < 3) {
$('#load_more_main_page').hide();
}
});
$scope.orderProp = 'popular';
$scope.response=[];
//LOADMORE
$scope.loadmore=function()
{
$http.get('profiles/profiles.php?profile_index='+$('#item-list .sub-item').length).success(function(response){
if(response) {
var reponseLength = response.length;
if(reponseLength > 1) {
$.each(response,function(index,item) {
$scope.Profiles.push({
UID: response[index].UID,
id: response[index].id,
popular: response[index].popular,
imageUrl: response[index].imageUrl,
name: response[index].name,
tags: response[index].tags,
category: response[index].category
});
});
}
if(reponseLength < 3) {
$('#load_more_main_page').hide();
}
}
});
}
}]);
/* App Module */
var profileApp = angular.module('profileApp', [
'ngRoute',
'profileControllers',
'profileServices',
]);
profileApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/profiles', {
templateUrl: 'partials/profile-list.html',
controller: 'profileListCtrl',
resolve: {
deps: function ($q, $rootScope) {
var deferred = $q.defer();
var dependencies = ['js/sort.js'];
$script(dependencies, function() {
$rootScope.$apply(function() {
deferred.resolve();
});
});
return deferred.promise;
}
}
}).
when('/profiles/:profileId', {
templateUrl: 'partials/profile-detail.html',
controller: 'profileDetailCtrl',
}).
when('/profiles/cat/:category', {
templateUrl: 'partials/profile-list-category.html',
controller: 'profileCategoryListCtrl',
}).
when('/create/', {
templateUrl: 'partials/profile-create.html',
controller: 'profileCreateCtrl',
css: ['css/createprofile.css','css/jquery-ui-1.10.4.custom.min.css','css/spectrum.css'],
}).
otherwise({
redirectTo: '/profiles'
});
}]);
लग रहा है। https://github.com/angular-ui/ui-router –
@ माइकरोबिन्सन मैंने अपने प्रश्न में एप्लिकेशन में इस्तेमाल किया गया कोड जोड़ा है, क्या आप कृपया सलाह दे सकते हैं कि मैं लोड-व्यू मॉडल को लोड से प्रीपेड डेटा के साथ कैसे रख सकता हूं विवरण दृश्य से वापस देखने के लिए वापस देखने पर कार्रवाई करने के लिए और अधिक कॉल करें? –