-
Understand the Use Case for Custom Directives
-
Create a Custom Directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | |
# Mayor.create(name: 'Emanuel', city: cities.first) | |
hippos = Hippo.create( | |
[{name:"Peter the Hippo",age:29,weight:2334,price:947.59}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('hipposApp', []) | |
.controller('HomeController', HomeController); | |
function HomeController($scope, $http) { | |
$http.get('/api/hippos') | |
.success(function(data) { | |
$scope.hippos = data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Add this HTML to the end of the existing HTML, just above the Socket.IO script. --> | |
<hr> | |
<div class="row"> | |
<div class="col-xs-4"> | |
<h4>Hippo Live Chat</h4> | |
</div> | |
<div class="col-xs-8 text-right"> | |
<label>Your Name:</label> <input type="text" ng-model="username"> | |
<button ng-click="sendMsg()" class="btn btn-success">Send Message</button> |
- Query a model using AR methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
**** ControllerAs Syntax **** | |
*/ | |
/* ControllerAs with an anonymous function & array annotation */ | |
angular | |
.module('myApp') | |
.controller('MainController', ['$http', function($http) { |
OlderNewer