实现$ rootScope函数和服务有什么区别?安全明智或表现明智.
我读过这个,所以我很想知道.
我一直试图弄清楚我的应用程序的某个全局函数是否最好在服务或$ rootScope本身中实现.为了让你们知道我在做什么,我正在开发一个脏表格功能,在这个功能中,如果他/她离开某个表格,它会提示用户.在这种情况下,我决定最好将它作为一个全局函数实现,所以任何提示?
谢谢你的回复,
一月
如何跨路线维护模型.例如,我有一个加载到主页的配置文件列表.主页还包含"加载更多"操作以加载更多配置文件,基本上将数据推送到模型.单击特定配置文件时,将通过路径激活该配置文件的详细视图.详细视图有一个后退按钮,可将用户重定向回主页.在路由回到主页时,由"加载更多"动作加载的数据(配置文件)将丢失.我需要使用"加载更多"前置数据来维护模型
以下是使用的代码
/* 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 …
Run Code Online (Sandbox Code Playgroud) angularjs angularjs-service angularjs-scope angularjs-routing ngroute