npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-get

v0.1.0

Published

This package centralizes the grunt work of setting up dynamic GET requests for data in Angular applications. Simply require the angular-get package and inject it into your main angular module. Then in your factories inject AppGet.

Downloads

2

Readme

What Does It Do?

This package centralizes the grunt work of setting up dynamic GET requests for data in Angular applications. Simply require the angular-get package and inject it into your main angular module. Then in your factories inject AppGet.

How to Use in Angular

npm install angular-get --save
var AppGet  = require('angular-get');
var angular = require('angular');


//This is your main angular module.
angular.module('YourApp', ['AppGet']) //Inject AppGet angular module.

//This is your factory, dependancy inject the AppGet Factory.
.factory('TestFactory', ['AppGet', function(AppGet){
    var TestFactory = {};
   TestFactory.get = AppGet.get('http://jsonplaceholder.typicode.com/comments?postId=[d]');

    TestFactory.get([1]).then(function(response){
         console.log(response); // [obj, obj, obj]
    })

    return TestFactory;
}]);

INITIALIZING A FACTORY TO USE AppGet

TestFactory.get = AppGet.get('http://jsonplaceholder.typicode.com/comments?postId=[d]');

WHAT IS REALLY HAPPENING

  • [d] is the dynamic parameter property, you can have many or as few or none.
  • If you have a dynamic paramter, it > MUST < be "[d]" in the assigning string.
  • When TestFactory.get([array of params]) is run, it will iterate over the array of params and inject them sequentially into the string prior to sending the request to the server.

RUNNING THE GET METHOD IN YOUR APP

TestFactory.get = AppGet.get('http://jsonplaceholder.typicode.com/comments?postId=[d]');

IMPORTANT get([Array]) accepts an array of params

  • Do not send in {} Objects, Strings, or arguments. ONLY arrays if params exist. TestFactory.get(["array"]) // good

  • If you have no params, do not include an empety array, leave it as get(). TestFactory.get()

  • if you have no params, your assigning string should not have a [d] in it 'http://...com/comments?postId=[d]' <-- dynamic param

  • Once the method runs, it will inject all the params into the request string 'http://...com/comments?postId=1' <-- once request is being called

RETRIEVING THE DATA

  • All GET methods in AppGet return back a promise. To retrieve the data, use the .then() funciton.
TestFactory.get([1]).then(function(response){
    console.log(response); // [obj, obj, obj]
    });

Example TestFactory > > ./test-factory.js

  • Check the npm_modules folder for the test-factory.js file. You can use this as base template and also test the AppGet module in your app.