Oleg | 11 Oct 23:03 2014
Picon

Re: How to create an oauth request?

Good!

Unfortunatelly it doesn't works with $resource, because I can't set `data` to $resource options (I can set only `params`, but params doesn't serialized to "X-WWW-FORM-URLENCODED")

вторник, 7 октября 2014 г., 15:21:09 UTC+4 пользователь Jonathan Bräuer написал:
Hi Oleg,

your problem is that your POST-data is serialized as "JSON", but it's expected to be serialized as "X-WWW-FORM-URLENCODED". Take a look at:

Johnny

On Tuesday, October 7, 2014 11:48:51 AM UTC+2, Oleg wrote:
How to create this request by $resource/$http

POST /oauth/token HTTP/1.1 Host: server.example.com Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW Content-Type: application/x-www-form-urlencoded grant_type=password&username=johndoe&password=A3ddj3wI use

$http({
  method: 'POST',
    data: {
      grant_type: 'password',
      username: 'johndoe',
      password: 'A3ddj3w'
    },
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      Authorization: 'Basic MTphMzJjMGZkM2EyNTUyYzZjMDNiOThiMTJlNTUyOWQwMQ=='
    }
 })

But my request look like:

  1. Remote Address:
  2. Request URL:
  3. Request Method:
    POST
  4. Status Code:
    404 Not Found
  5. Request Headersview source
    1. Accept:
      application/json, text/plain, */*
    2. Accept-Encoding:
      gzip,deflate
    3. Accept-Language:
      ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
    4. Authorization:
      Basic MTphMzJjMGZkM2EyNTUyYzZjMDNiOThiMTJlNTUyOWQwMQ==
    5. Cache-Control:
      no-cache
    6. Connection:
      keep-alive
    7. Content-Length:
      67
    8. Content-Type:
      application/x-www-form-urlencoded
    9. Cookie:
      sid=s%3ASlH1ffec8ImuCK3Bc8KyB5qMNlVroUoL.nLeKljOhlR2rxOJUvGwb8Xc0ILRwIHrqg2GMlC77N1I
    10. Host:
      localhost:8001
    11. Origin:
    12. Pragma:
      no-cache
    13. Referer:
    14. User-Agent:
      Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
  6. Form Dataview sourceview URL encoded
    1. {"grant_type":"password","username":"johndoe","password":"A3ddj3w"}:
  7. Response Headersview source
    1. Connection:
      keep-alive
    2. Content-Type:
      text/plain
    3. Date:
      Tue, 07 Oct 2014 09:42:27 GMT
    4. Transfer-Encoding:
      chunked

--
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/d/optout.
César Costa | 11 Oct 20:56 2014
Picon

Undefined Directive Controller

Hi,

I implemented a parent directive that have two child directives. When the user click in button inside child-one directive i need to toggle a content from child-two directive. But, the parent controller inject on childs directive are undefined. 

This plunker show my case:

http://plnkr.co/edit/tVBYIE?p=preview

Can anyone help me?


--
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/d/optout.
steven smock | 11 Oct 15:44 2014
Picon

View-Model Design: Extensions and Mixins?

In creating controllers, I have adopted an "orthodox" technique like the one recently discussed here: The "Dot" in the model.

A nice byproduct (I think) of the "always use a view-model" approach is that these models can easily be extended, either prototypically or mixin-style, via methods on an "extender" or "mixer" service.  

So far, I have really profited from the mixin service approach, extending my view-models to give them a set of standard behaviors (i.e. properties and methods) relevant to common business needs:
  • Paged lists
  • Entry forms
  • Sub-navigation (i.e. "nested views")
  • Configurable toolbars
But wait: can't we implement those sorts of behaviors via directives?  Of course we can.  But extending a controller's view-model (I think) is both simpler and more flexible.  Here is why:
  1. Members can be more easily shared (i.e. you don't need to worry about binding, isolate scopes, etc. that come with directives)
  2. You don't need to commit to a directive's UI
  3. It's just simple OOP -- your logic isn't married to view-models (or even Angular, for that matter), in case you want to use it elsewhere; it can also be more easily tested for this reason
I know this is fairly very abstract, but I would like to ask the group:
  • What do you think of this approach?
  • If you are doing something similar, how have you chosen to implement it?
  • What are some common patterns of controller behavior that could be implemented neatly with this technique?

--
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/d/optout.
srn | 11 Oct 11:15 2014
Picon

how to get function data into scope varaible in angular js

below is my code i need to get username controller is loginname i need to get the name 




function loginname($scope) {
       
   

    var context = SP.ClientContext.get_current();
    var user = context.get_web().get_currentUser();
    var name;


    angular.element(document).ready(function () {
        getUserName();

        context.load(user);

        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);

    });

   

    // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
   // $(document).ready(function () {
       // getUserName();
   // });

    // This function prepares, loads, and then executes a SharePoint query to get the current users information
    function getUserName() {
        context.load(user);
      
        context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
    }

    // This function is executed if the above call is successful
    // It replaces the contents of the 'message' element with the user name
    function onGetUserNameSuccess() {
        $('#message').text('Hello ' + user.get_title());
       
        name = user.get_title();
        alert(name);
       
      
    }

    // This function is executed if the above call fails
    function onGetUserNameFail(sender, args) {
        alert('Failed to get user name. Error:' + args.get_message());
    }



   $scope.lastName = name;
   // alert("sssssssss"+name);


    //var userid = _spPageContextInfo.userId;
    //var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
    //var requestHeaders = { "accept": "application/json;odata=verbose" };

   
    //$http({ method: 'GET', url: requestUri, headers: requestHeaders }).success(function (data) {
    //    $scope.collection = data;
    //    // response data 
    //});
    }

--
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/d/optout.
Benedikt M. | 11 Oct 00:19 2014
Picon

decorator for ui-bootstrap tooltip

Hi,

I want to overwrite the show() function in line  168 from https://github.com/angular-ui/bootstrap/blob/master/src/tooltip/tooltip.js.
I figuret out, that it is easy to overwrite simple services with the $provide.decorator() function from angular.
But the .provider( '$tooltip', function () {...}) service here is to complex for me.
Can somebody give me a hint how the decorator should looks like to overwrite the show() function in https://github.com/angular-ui/bootstrap/blob/master/src/tooltip/tooltip.js.?

Tahnks and best regards
Benedikt

--
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/d/optout.
Leonan Luppi | 10 Oct 23:43 2014
Picon

Simple Rest API

Hello all,

So I create a simple Rest API to help calls RestFull:

angular.module('voip.services').service('RestAPI', function ($http, $q) {
var _restAPI = {};
var _urlBase = '';
var _deferred;

_restAPI.setUrl = function(urlBase) {
_urlBase = urlBase;
}

_restAPI.getUrl = function() {
return _urlBase;
}

_restAPI.findAll = function() {
_deferred = $q.defer();
$http.get(_urlBase).success(function(data){
_deferred.resolve(JSON.parse(data["DATA"]));
}).error(function(err, status){
_deferred.reject(err["MSG_ERROR"]);
});
return _deferred.promise;
}

_restAPI.create = function(grupo) {
_deferred = $q.defer();
$http.post(_urlBase, grupo).success(function(data) {
_deferred.resolve(JSON.parse(data["DATA"]));
}).error(function(err, status) {
_deferred.reject(err["MSG_ERROR"]);
});
return _deferred.promise;
}

_restAPI.update = function(id) {
_deferred = $q.defer();
$http.put(_urlBase + "/:id", id).then(function(response) {
_deferred.resolve(JSON.parse(data["DATA"]));
}, function(err){
_deferred.reject(err["MSG_ERROR"]);
});
}

_restAPI.destroy = function(id) {
_deferred = $q.defer();
$http.delete(_urlBase + "/:id", id).then(function(response) {
_deferred.resolve(JSON.parse(data["DATA"]));
}, function(err){
_deferred.reject(err["MSG_ERROR"]);
});
}

return _restAPI;
});

I hope you like, is just for study but if help someone I'll be very happy. 

--
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/d/optout.
Clinton Buie | 10 Oct 22:52 2014
Picon

ECONNREFUSED: with corporate proxyasd

Hi,

I've attempted to run Protractor with my sauce credentials, but unfortunately, I'm not able to connect through my corporate proxy.

conf.js:

exports.config = {
//seleniumAddress: 'https://gego:ff82602e-4e98-4386-99b1-bb46ac7130d5 <at> ondemand.saucelabs.com:80/wd/hub',
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
specs: ['spec.js'],
capabilities: {
'browserName': 'chrome',
'proxy': {

'proxyType': 'manual',
'httpProxy': 'http://proxy-src.research.ge.com:8080',
}
}
}

Error message:

Using SauceLabs selenium server at http://ondemand.saucelabs.com:80/wd/hub

/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:136
callback(new Error(message));
^
Error: ECONNREFUSED connect ECONNREFUSED
at ClientRequest. (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:136:16)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketErrorListener (http.js:1547:9)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:440:14
at process.tickCallback (node.js:419:13)
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession(/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:49)
at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:111:30)
at Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:106:20)
at SauceDriverProvider.getDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/sauce.js:102:53)
at /usr/local/lib/node_modules/protractor/lib/runner.js:241:41
at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:573:44

Any ideas on what could be causing this error?  I'm not attempting to communicate back to my company (no need for Sauce Connect), rather this is the step for running a test application and url with Sauce Labs.

--
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/d/optout.
Olivier Clément | 10 Oct 17:09 2014
Picon

Opinion wanted: Testing Angular Project -> Protractor + Jasmine/Mocha/etc or The Intern?

Hi all, 

I was just starting looking into The Intern project and find it quite interesting despite its use of AMD modules (which I personally don't really like compared to commonJS, but that's me)

And then there's of course Protractor tailored for Angular that does part of what the Intern does.
And naturally there comes the question: what would be an optimal, easiest to use solution for complete testing of an angular project?

The Intern seems to offer quite a lot in one package: E2E, Behavior and Unit Testing, Reporting, Coverage, etc. easy integration with browserstack/saucelabs if needed (although it's probably not something we'd use internally at my workplace)

While it seems the more "traditional" solution for angular projects  is to manually setup the different puzzle pieces together, involving (probably) more work, at least initially.

So what's the community's opinion on this, preferred solution to have a compelte testing solution for your projects?
I am specifically thinking about Single Page Apps here


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/d/optout.
Guilherme ferreira | 10 Oct 16:38 2014
Picon

Connect API Restfull Silex

Hello,

how do I connect the Angularjs in an api?

my api call a function !!

$username = $app['request']->server->get('PHP_AUTH_USER', false);
    $password = $app['request']->server->get('PHP_AUTH_PW');

    if (($app['config']['auth']['user'] != $username) && ($app['config']['auth']['password'] != $password) ) {

        $response = new Response();
        $response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', 'site_login'));
        $response->setStatusCode(401, 'Please sign in.');
        return $response;

    }


thanks for 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/d/optout.
lucian enache | 10 Oct 15:20 2014
Picon

continuous keyboard navigation over multiple ul lists

What I want to achieve is to be able to navigate over multiple ul lists with keyboard arrows,

currently I am using the $index in order to determine which item is highlighted but when I have
multiple ul's the $index is the same for both lists therefore the highlight is duplicated.

how can I achieve a continuous navigation, I was considering combining the items in one 
unique list but then I have no categories since each list should be a category and the titles 
of the categories should be left out of the navigation.

here is an example of what I have managed to achieve so far :http://plnkr.co/edit/L6nZIYanQcDbQonh4zdl?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/d/optout.
Kasper Gantzhorn | 10 Oct 13:43 2014
Picon

Update input model value from another input field

Hi everyone,
I'm pretty new to Angular, so bear with me.
I have an input field (Company) where the user can write a company name, and as the user types (change()) I make a $http look-up in an VATapi to find the corresponding VAT number (8 characters).
When I find the right number I would like to update another input field (VATnr.) with this value. The problem is, that when I put 

ng-minlength=8 ng-maxlength=8


on the VATnr. input field the number is not updated in the (VATnr.) input field. I've also tried 

ng-minlength="8" ng-maxlength="8"



This is the code
//THE TWO INPUT FIELDS
<input type="text" name="company" placeholder="Indtast firmanavn" ng-model="user.company" ng-change="checkCVR()" ng-keydown="cvrKeyDown($event)" required>

<input type="text" name="cvr" placeholder="Indtast virksomhedens CVR.nr." ng-model="user.cvr" ng-minlength=8 ng-maxlength=8 integer required>




//THE CONTROLLER
$scope.checkCVR = function()
      {

      $http.jsonp('http://cvrapi.dk/api?callback=JSON_CALLBACK&search=' + $scope.user.company + '&country=dk')
      .success(function(data, status, headers, config) 
      {
      $scope.compnay_name = data.name;
      $scope.compnay_vat = data.vat;


})
      }

            

      $scope.cvrKeyDown = function($event)
      {
      if($event.keyCode == 13)
      {
      $event.preventDefault();
      $scope.user.cvr = $scope.compnay_vat;
      }


      }


      $scope.updateCVRvat = function()
      {
      $scope.user.cvr = $scope.compnay_vat;
      }



Also, I would like to make the CVRnr input field only validate, when the user types in numbers. I cannot use the type="number" attribute.


Thanks guys.
Kasper

--
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/d/optout.

Gmane