Presented by Tejus Parikh, CTO and Co-Founder
Rivalry is built with AngularJS and Rails. We provide analytics, reports, and (most importantly) allow sales managers to coach their sales reps.
Our application has to be easier and more useful than Salesforce, email, and spreadsheets.
![]() |
CTO and co-founder of Rivalry |
Relevant Experience
High level view
Skip some of the basics (adding scripts, adding css, etc)
Don't fret, there are easier ways to get started
You'll need one *.erb
<html>
<head>
...
<%= csrf_meta_tags %>
</head>
...
<body ng-app='rivalry'>
</body>
</html>
(function() {
var module_deps = ['ngRoute', 'ngResource', ...];
var rivalry = angular.module('rivalry');
rivalry.config(['$httpProvider', providerInitFunc]);
function providerInitFunc($httpProvider) {
/* include the rails CSRF token when making AJAX calls */
$httpProvider.defaults.headers.common['X-CSRF-Token'] =
$('meta[name=csrf-token]').attr('content');
}
});
<html>
...
<body ng-app='rivalry'>
<div ng-view></div>
</body>
</html>
ngRoute is the official router
There are alternatives under active development
.when('/', {
controller: 'DashboardCtrl',
templateUrl: '/assets/home/dashboard.html'),
activeTab: ['home', 'dashboard'],
reloadOnSearch: true
})
Create a file /assets/home/dashboard.html
<h2>Hi there {{user.name}}</h2>
(function(module) {
var ctrldef = ['$scope', 'User', DashboardCtrlFunc];
module.controller(ctrldef);
function DashboardCtrlFunc($scope, User) {
$scope.user = User.get({'id': user.id})
}
})(angular.module('rivalry'));
(function(module) {
var userdef = ['$resource', UserFunc];
module.factory('User', userdef);
function UserFunc($resource) {
var params = {'id': '@id'};
var commands = {'update': {'method': 'PUT'}};
return $resource('/users/:id.json', params, commands);
}
})(angular.module('rivalry'));
Handwave, it's done!
class UserController < ApplicationController
load_and_authorize_resource :user
def show
respond_with @user
end
end
{{user.name}}
Gets automatically templated
Tejus Parikh
Both the good, the bad, and the ugly
Here are some of the features we really find awesome
Control logic is markup independent
Can reuse views and controllers independently
Directives are like JQuery Plugins on Steroids
Encapsulate and reuse code
{{someCalculatedValue()}}
function UserItemCtrl($scope) {
$scope.someCalculatedValue = function() {
return doSomething($scope.user);
}
}
$scope.user = User.get({'id': user.id});
$scope.user.$update(successCallback, errorCallback);
Especially nice for manipulating lists
ngRoute and it's alternatives allow for linking into the app
We use this within our emails
Aspects that I'm not fond of
Loading or no data? How do you tell?
Hey there, {{user.name}}, are you bored?
Renders to this if your server is slow
Hey there, , are you bored?
Forget an argument, prepare for staring at a 10,000k line of JS
Similar, but have different API's and usage restrictions.
Ready flamethrowers...
Happens 1/20 times
Iterator with a controller. Html includes a directive.
Controller is trying to access a value on $scope
before the directive puts it there
The resulting undefined
kills the loop
Fixed with $timeout
or $watch
AngularJS 2.x is a massive improvement
AngularJS 2.x is completely new api
http://eisenbergeffect.bluespire.com/all-about-angular-2-0/
A lot of Angular's problems are RIA in the browser problems
Or tell me why I should love Angular
PS. We're hiring. Email tejus@rivalry.com