Git Product home page Git Product logo

angular-directives's Introduction

#Angular Directives

Directives are great for making portable/reusable modules. Once you create a directive, it can be used across many potential projects. In the starter code, we've provided an app setup with a sample directive. Let's create, test, and display two additiona directives.

####Like button

Create a like button directive with a counter. When loaded in to a page, there should be a button that says "like". When you click the button, the counter should go up by 1. For the purposes of this assignment, allow a single user to click the like button as much as they want so each click will increase the number displayed on the button by 1.

The button should have 1 optional parameter starting-value which will set the starting value of the like button. If ommitted the values should start at 0.

Usage

<like-button starting-value="5"></like-button>

The above code should add a like button to the page which will display "Likes: 5". When clicked it would update to "Likes: 6" and so on...

Additionally, you should be able to have multiple like buttons on a single page that each keep their own separate count.

<like-button></like-button>

<like-button starting-value="1"></like-button>

<like-button starting-value="3"></like-button>

####Weather

We will create a widget that will display the current weather. Using $http to send a call to openweathermap.org.

Usage

<weather location="Seattle,WA"></weather>

The above code should load the current weather conditions for Seattle, WA. You should be able to include different locations.

API URL

http://api.openweathermap.org/data/2.5/weather?q=Seattle,wa

Note that you'll need an API key to access this API. For this assignment, you can hardcode the key into the URL.

####Bonus

Dynamic Model

Add an ng-location parameter in the <weather> directive that can be bound to a scope variable. Test this by creating a text box where the user can enter a location and have the weather update dynamically.

GPS

Use html5 geolocation to make the <weather> directive load the current weather based on the users current location ONLY if location and ng-location are ommitted. the location and ng-location parameters should still work.

<!-- Displays weather for Seattle, WA -->
<weather location="Seattle,WA"></weather>

<!-- Displays weather for the value of $scope.location -->
<weather ng-location="location"></weather>

<!-- Displays weather for users current location -->
<weather></weather>

angular-directives's People

Contributors

bhague1281 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.