Tony Polinelli | 17 Jul 01:18 2013

Re: How to change the scope of Controller in directive?

You should maybe use events to communicate between your controllers - just $emit one up to the main


On Tue, Jul 16, 2013 at 7:10 AM, Grant Rettke <grettke <at> acm.org> wrote:
On http://docs.angularjs.org/guide/directive

Under the section "Directive Definition Object"

The 'scope' parameter documents how to inherit scope, or not.

On Tue, Jul 16, 2013 at 9:03 AM, Nsyiio Lee <nsyiio <at> gmail.com> wrote:
> I want to change the value of scope in directive, how?
> This is a demo code http://plnkr.co/edit/7M4DrTdhI1QQrOtS2U9M?p=preview
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+unsubscribe <at> googlegroups.com.
> To post to this group, send email to angular <at> googlegroups.com.
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Grant Rettke | ACM, AMA, COG, IEEE
grettke <at> acm.org | http://www.wisdomandwonder.com/
"Wisdom begins in wonder." --Socrates
((λ (x) (x x)) (λ (x) (x x)))
"Life has become immeasurably better since I have been forced to stop
taking it seriously." --Thompson

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.





--
Tony Polinelli
http://touchmypixel.com

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Wenjie Fan | 17 Jul 03:43 2013
Picon

Re: I cannot get callback when $http request timeout

I was wondering why I'm the only one to see such obvious issue, eventually it turns out to be that my firefox browser is too old. I'm running firefox v3.6 and I never get callback invoked when http request times out. When I use chrome or safari, the callback did get invoked. I will upgrade my firefox and try again later.


Thanks everyone......


On Tuesday, July 16, 2013 2:57:50 PM UTC+8, Wenjie Fan wrote:
I'm using $http service to send request to server. I found if http request timeout, I cannot get any callback or notify. Something even worth that the request is always kept in $http.pendingRequests array, never removed. I have tried both 1.0.7 and 1.1.5 version, the same.

I appreciate if anyone can provide some suggestions on this issue.


Here is sample code:

$http({method: 'POST', url: '/someurl', timeout : 10000,data: obj})
    .success(function(data, status, headers, config) {
        // do something
    })
    .error(function(data, status, headers, config) {
        // do something
    });

If response is not return in 10 seconds, neither success nor error function get invoked and the request is never removed from $http.pendingRequests array....

Thanks.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Nsyiio Lee | 17 Jul 04:14 2013
Picon

Re: How to change the scope of Controller in directive?

Yes, i'm using this way already, i post this question because i want to know whether there is a better and easy way to do that.
Thank you all the same.

On Wednesday, July 17, 2013 7:18:41 AM UTC+8, Tony Polinelli wrote:

You should maybe use events to communicate between your controllers - just $emit one up to the main


On Tue, Jul 16, 2013 at 7:10 AM, Grant Rettke <gre... <at> acm.org> wrote:
On http://docs.angularjs.org/guide/directive

Under the section "Directive Definition Object"

The 'scope' parameter documents how to inherit scope, or not.

On Tue, Jul 16, 2013 at 9:03 AM, Nsyiio Lee <nsy... <at> gmail.com> wrote:
> I want to change the value of scope in directive, how?
> This is a demo code http://plnkr.co/edit/7M4DrTdhI1QQrOtS2U9M?p=preview
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to angular+u... <at> googlegroups.com.
> To post to this group, send email to ang... <at> googlegroups.com.
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Grant Rettke | ACM, AMA, COG, IEEE
gre... <at> acm.org | http://www.wisdomandwonder.com/
"Wisdom begins in wonder." --Socrates
((λ (x) (x x)) (λ (x) (x x)))
"Life has become immeasurably better since I have been forced to stop
taking it seriously." --Thompson

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u... <at> googlegroups.com.
To post to this group, send email to ang... <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.





--
Tony Polinelli
http://touchmypixel.com

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Paul McCaughtry | 17 Jul 05:23 2013
Picon

What is the Angular way to display navigation conditionally? (i.e., display nav after successful authentication)

Hi,


I am new to Angular and evaluating it for a future project. I have some experience with Backbone and would like to know how to approach dynamic display of navigation once a user has logged into to the site (the Angular way). Basically, users shouldn't see the navigation until successful authentication.

Since there is only one ng-view without the angular-ui routes, I have the navigation in the html and would like to add a class "hidden" (display: none) to the nav container until a user successfully authenticates.

So far I've tried unsuccessfully setting ng-class on the navigation container, tying the true/false classes to a variable set at $rootScope.

I have also tried, unsuccessfully, adding a class based on route path (i.e. if $location.path() === '/' add class 'hidden'). The outcome is as desired on the login page (no navigation) but once the login redirects to the proper route, the navigation is still hidden. If I refresh the page, the navigation appears as intended.

The nav container has ngController set to NavCtrl below that tests the route path for the scenario above.

Thank you. 


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Grant Rettke | 17 Jul 05:37 2013
Picon

Re: What is the Angular way to display navigation conditionally? (i.e., display nav after successful authentication)

On Tue, Jul 16, 2013 at 10:23 PM, Paul McCaughtry <pm2731 <at> gmail.com> wrote:
> Basically, users shouldn't see the navigation until successful authentication.

We:

1. Listen for route change success and if they are not authenticated
or authorized redirect them to a welcome page.
2. Display a menu restricted by authentication and authorization.
3. Services are all locked down.

If they want to hack around it in the GUI, they of course will,
regardless of the approach.

Josh David Miller | 17 Jul 05:49 2013

Re: What is the Angular way to display navigation conditionally? (i.e., display nav after successful authentication)

The simplest thing is just a service. Whatever you use to authenticate users has a simple isLoggedIn method you can call. Watch this from your main controller and then simple use ngShow.

$scope.$watch( function () { return authService.isLoggedIn(); }, function ( isLoggedIn ) {
  $scope.isLoggedIn = isLoggedIn;
});

<ul ng-show="isLoggedIn">
   ...
</ul>

Josh
(Sent from my mobile)

On Jul 16, 2013 8:37 PM, "Grant Rettke" <grettke <at> acm.org> wrote:
On Tue, Jul 16, 2013 at 10:23 PM, Paul McCaughtry <pm2731 <at> gmail.com> wrote:
> Basically, users shouldn't see the navigation until successful authentication.

We:

1. Listen for route change success and if they are not authenticated
or authorized redirect them to a welcome page.
2. Display a menu restricted by authentication and authorization.
3. Services are all locked down.

If they want to hack around it in the GUI, they of course will,
regardless of the approach.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Mark | 17 Jul 06:11 2013
Picon

Documentation suggestion

Hi,


One of the confusing aspects in Angular is figuring out if you're in Angular land or not.
For example: prior to 1.1.4 $http got you into Angular execution context - but this has changed (and caused dozens of useless bug reports on Github and I'm sure lots of lost development time).
$timeout brings you into Angular context.
$scope.$on does not, but wrapping the $broadcast call in $apply will fix that
etc etc
It would be very helpful if the developer guide gave a clear, concise explanation of when we're in Angular context, when we're not,
and strategies on handling such situations

Thanks
-Mark

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
John Walker | 17 Jul 06:21 2013

Global Cache Bust

Hello,


I would like to add a cache buster to ALL partials htmls and javascript/css file imports. Is there a way to append something like .html?cach-bust=versionNumber to /app.js?cach-bust=versionNumber to all calls. 
What i dont want to do is copy and paste that onto every partial template call or file import. Is there a way to do this globally in Angular? Or is there a better way to do this? My issue is i test locally, and everything works great. Then i upload the application to google app engine, and have to wait 10 minutes to test new code. Even if i clear chromes cache.

Thanks for any help!

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
abe | 17 Jul 06:26 2013
Picon

Passing a bound variable to ng-click for dynamic click handler

I have the following dom.

       <td grid-item ng-repeat='col in columnDefs' ng-click="actions[col.field]"></td>

This is wrapped in a directive:

    angular.module('myApp').
    directive('gridItem', function () {
        return {
            restrict: 'A',
            templateUrl: 'views/grid_item.html',
            link: function postLink(scope, element, attrs) {
                if (scope.$eval(element.attr('ng-click'))) {
                    element.addClass('clickable');
                }
            }
        };
    });

For clarity: 
actions is an Object of the format:

       {some_column: '', some_other_column: 'myFunction(arguments)', some_third_column: 'myOtherFunction(arguments)'}

and `col.field` will be `some_column`, `some_other_column`, etc depending on the particular iteration

This binds fine and adds the clickable class to the elements where ng-click is non-blank.

However, the method on the controller is never called. Why is this? And how can I bind dynamically to a function based off a string representation?

The string representation of activity[col.field] (in this case) is: `fetch('activity', $parent.$index)`.

The controller is certainly in scope as it is defined through the `controller:` key on a parent directive with (unsure if this is relevant) isolate scope.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
fess | 17 Jul 06:39 2013
Picon

Re: How to change the scope of Controller in directive?

in your example your directive isn't creating a new scope so it shares the same scope created by
ng-controller="MainCtrl"   so   all you have to do is modify the scope.  which you're doing.  the only thing
you're missing is the $digest run that comes from using scope.$apply

here's an updated  plunk:     http://plnkr.co/edit/mufVrSV4B1dYjCLDOMbP?p=preview

if your directive did create a new scope.   then you could use events.   you also have access to scope.$parent if
you wanted to modify it directly but events is probably a better way to go.

All in all I'm finding that angular has plenty of rope to hang yourself with.  best practices are even harder
won then a basic understanding.  :)  best of luck. 

On Jul 16, 2013, at 7:14 PM, Nsyiio Lee wrote:

> Yes, i'm using this way already, i post this question because i want to know whether there is a better and
easy way to do that.
> Thank you all the same.
> 
> On Wednesday, July 17, 2013 7:18:41 AM UTC+8, Tony Polinelli wrote:
> You should maybe use events to communicate between your controllers - just $emit one up to the main
> 
> 
> On Tue, Jul 16, 2013 at 7:10 AM, Grant Rettke <gre... <at> acm.org> wrote:
> On http://docs.angularjs.org/guide/directive
> 
> Under the section "Directive Definition Object"
> 
> The 'scope' parameter documents how to inherit scope, or not.
> 
> On Tue, Jul 16, 2013 at 9:03 AM, Nsyiio Lee <nsy... <at> gmail.com> wrote:
> > I want to change the value of scope in directive, how?
> > This is a demo code http://plnkr.co/edit/7M4DrTdhI1QQrOtS2U9M?p=preview
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "AngularJS" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to angular+u... <at> googlegroups.com.
> > To post to this group, send email to ang... <at> googlegroups.com.
> > Visit this group at http://groups.google.com/group/angular.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> 
> 
> 
> --
> Grant Rettke | ACM, AMA, COG, IEEE
> gre... <at> acm.org | http://www.wisdomandwonder.com/
> "Wisdom begins in wonder." --Socrates
> ((λ (x) (x x)) (λ (x) (x x)))
> "Life has become immeasurably better since I have been forced to stop
> taking it seriously." --Thompson
> 
> --
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to angular+u... <at> googlegroups.com.
> To post to this group, send email to ang... <at> googlegroups.com.
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> 
> 
> -- 
> Tony Polinelli
> http://touchmypixel.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
> To post to this group, send email to angular <at> googlegroups.com.
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

--

-- 
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe <at> googlegroups.com.
To post to this group, send email to angular <at> googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


Gmane