could not get the property value of my object in angularJs

I get undefined whenever I get the value of a property of an object. function run(id){ var report = services.getReportInfo(id); var childReport = { id: newGuid(), parentId: report.id, // i get undefined reportPath: report.path // i get undefined }; ... } services.js angular.module('project.services').factory('services', function(){ var reports = [

无法在angularJs中获取我的对象的属性值

每当我获得对象属性的值时,我都会得到undefined的值。 function run(id){ var report = services.getReportInfo(id); var childReport = { id: newGuid(), parentId: report.id, // i get undefined reportPath: report.path // i get undefined }; ... } services.js angular.module('project.services').factory('services', function(){ var reports = [ { ....

Angular service variables not updating

I have the following service (pseudo code) app.service('user', function($http) { function login(email, password, callback) { // login user // set isLoggedIn to true // assign the returned user object to userData // issue callback }; return { isLoggedIn: false, userData: null, login: login }; }); Here is my login controller

角度服务变量没有更新

我有以下服务(伪代码) app.service('user', function($http) { function login(email, password, callback) { // login user // set isLoggedIn to true // assign the returned user object to userData // issue callback }; return { isLoggedIn: false, userData: null, login: login }; }); 这是我的登录控制器: app.controller('LoginCont

How to store User Data in AngularJs

Can anyone please let me know how to store logged in user data into global scope of AngularJS, My Login services is looked like this App.service('Auth', function($http){ return { isLogin:function(callback){ $http.get('api/auth/checkLogin').success(function(res){ callback(res); }); }, login:function(user, callback){

如何在AngularJs中存储用户数据

任何人都可以让我知道如何将登录的用户数据存储到AngularJS的全球范围内, 我的登录服务看起来像这样 App.service('Auth', function($http){ return { isLogin:function(callback){ $http.get('api/auth/checkLogin').success(function(res){ callback(res); }); }, login:function(user, callback){ $http.post('api/auth/login', user).su

AngularJS: $scope is not defined?

I've started learning Angular JS ,I keep getting '$scope is not defined' console errors for this controller code in AngularJS: any idea ? Service :signup.js 'use strict'; angular.module('crud') .service('Signup',function () { var data={ email:$scope.email,password:$scope.password,confirmPassword:$scope.confirmPassword } //console.log(data); $s

AngularJS:$ scope没有定义?

我已经开始学习Angular JS,在AngularJS中我一直在为这个控制器代码获取'$ scope is not defined'控制台错误:任何想法? 服务:signup.js 'use strict'; angular.module('crud') .service('Signup',function () { var data={ email:$scope.email,password:$scope.password,confirmPassword:$scope.confirmPassword } //console.log(data); $sails.post("/api/user",data)

AngularJS pass data from controller to another controller

What I have done. I retrieve a list of videos from youtube api with json in a controllerA with specific directive. The json contain the list of video and the video itself details. What I want to do. When click on a video, I want the video's details display in another ng-view with other controllerB with using the json data I request before. So my question is How to pass the data from co

AngularJS将数据从控制器传递到另一个控制器

我做了什么。 我用带有特定指令的controllerA中的json检索youtube api中的视频列表。 json包含视频列表和视频本身的详细信息。 我想做的事。 点击视频时,我希望视频的详细信息以其他控制器B的另一个ng视图显示,并使用之前请求的json数据。 所以我的问题是如何将数据从控制器A传递给控制器​​B. 注 - $ controller服务在controllerA中使用 这是从AngularJS开始的常见疑问之一。 根据你的要求,我相信你最好的选择是

different ways to create controllers and services, why?

I keep seeing different examples of creating controllers and services in AngularJS and I'm confused, can anyone explain to me the differences between the two approaches? app.service('reverseService', function() { this.reverse = function(name) { return name.split("").reverse().join(""); }; }); app.factory('reverseService', function() { return { reverse : function(

不同的方式来创建控制器和服务,为什么?

我不断看到在AngularJS中创建控制器和服务的不同例子,我很困惑,任何人都可以向我解释两种方法之间的区别吗? app.service('reverseService', function() { this.reverse = function(name) { return name.split("").reverse().join(""); }; }); app.factory('reverseService', function() { return { reverse : function(name) { return name.split("").reverse().join("");

Update parent scope variable in angular

I have two controllers one wrapped within another. Now I know the child scope inherits properties from the parent scope but is there a way to update the parent scope variable? So far I have not come across any obvious solutions. In my situation I have a calendar controller within a form. I would like to update the start and end dates from the parent scope (which is the form) so that the form

更新父范围变量的角度

我有两个控制器一个包裹在另一个。 现在我知道子范围从父范围继承属性,但有没有办法更新父范围变量? 到目前为止,我还没有遇到任何明显的解决方案。 在我的情况下,我在表格中有一个日历控制器。 我想从父作用域(这是表单)更新开始日期和结束日期,以便表单在提交时具有开始日期和结束日期。 您需要在父范围中使用对象(不是基元),然后您将能够直接从子范围更新它 家长: app.controller('ctrlParent',function($

AngularJS module: this versus $scope

This question already has an answer here: 'this' vs $scope in AngularJS controllers 7 answers The two implementations are used differently in the view. The this syntax is used together with the controller as syntax, which essentially makes your controller your view model. controller as example In Controller this.text = "Controller as example" In View <div ng-controller="myC

AngularJS模块:这与$范围

这个问题在这里已经有了答案: AngularJS控制器中的'this'与$ scope有关的7个答案 这两种实现在视图中使用不同。 这个语法与控制器一起用作语法,这实际上使得你的控制器成为你的视图模型。 控制器为例 在控制器中 this.text = "Controller as example" 在视图中 <div ng-controller="myCtrl as controllerViewModel"> {{controllerViewModel.text}} </div> 范围等同 在控制器中 $scope.

Angular controller

This question already has an answer here: 'this' vs $scope in AngularJS controllers 7 answers When you are trying to minify the code, at that time angular.module('myApp', []) .controller('SomeController', ['$scope', function($scope) { $scope.qty = 1; }]); Would be useful to inject the dependencies properly.

角控制器

这个问题在这里已经有了答案: AngularJS控制器中的'this'与$ scope有关的7个答案 当时你试图缩小代码 angular.module('myApp', []) .controller('SomeController', ['$scope', function($scope) { $scope.qty = 1; }]); 对正确注入依赖关系很有用。

Difference between $scope and this in controller context?

This question already has an answer here: 'this' vs $scope in AngularJS controllers 7 answers The difference is the scope of the object you're interacting with. $scope is an object injected into your controller. Your controller is an object representative of a given piece of your angular application. Earlier on in Angular, controllers weren't objects. They are now. You

控制器上下文中$ scope与this之间的区别?

这个问题在这里已经有了答案: AngularJS控制器中的'this'与$ scope有关的7个答案 区别在于您正在与之交互的对象的范围。 $scope是一个注入你的控制器的对象。 你的控制器是你的角度应用程序的一个代表对象的代表。 在Angular早些时候,控制器不是对象。 他们现在。 你应该没问题(如果你关心哪一个是正确的),但是controller as要更简洁一些。