added dynamic title

This commit is contained in:
Mario Colque 2014-01-27 15:39:59 -03:00
parent a40b87c4b6
commit f09c041efa
7 changed files with 47 additions and 27 deletions

View File

@ -4,7 +4,7 @@ head
meta(name='viewport', content='width=device-width,initial-scale=1.0')
meta(name="fragment", content="!")
title= appName+' - '+title
title(data-ng-bind="$root.title + $root.titleDetail + ' | #{appName}'")= appName
meta(http-equiv='Content-type', content='text/html;charset=UTF-8')
meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs")
meta(name="description", content="Insight")

View File

@ -1,7 +1,7 @@
doctype html
html(lang='en', xmlns='http://www.w3.org/1999/xhtml')
html(lang='en', xmlns='http://www.w3.org/1999/xhtml', data-ng-app='insight')
include ../includes/head
body(data-ng-app='insight')
body
#wrap
include ../includes/navbar
block content

View File

@ -1,44 +1,56 @@
'use strict';
//Setting up route
angular.module('insight').config(['$routeProvider',
function($routeProvider) {
$routeProvider.
angular.module('insight').config(function($routeProvider) {
$routeProvider.
when('/block/:blockHash', {
templateUrl: '/views/block.html'
templateUrl: '/views/block.html',
title: 'Bitcoin Block '
}).
when('/block-index/:blockHeight', {
controller: 'BlocksController',
templateUrl: '/views/redirect.html'
}).
when('/tx/:txId', {
templateUrl: '/views/transaction.html'
templateUrl: '/views/transaction.html',
title: 'Bitcoin Transaction '
}).
when('/', {
templateUrl: '/views/index.html'
templateUrl: '/views/index.html',
title: 'Home'
}).
when('/blocks', {
templateUrl: '/views/blocks/list.html'
templateUrl: '/views/blocks/list.html',
title: 'Bitcoin Blocks solved Today'
}).
when('/blocks-date/:blockDate', {
templateUrl: '/views/blocks/list.html'
templateUrl: '/views/blocks/list.html',
title: 'Bitcoin Blocks solved '
}).
when('/address/:addrStr', {
templateUrl: '/views/address.html'
templateUrl: '/views/address.html',
title: 'Bitcoin Address '
}).
when('/status', {
templateUrl: '/views/status.html'
templateUrl: '/views/status.html',
title: 'Status'
}).
otherwise({
templateUrl: '/views/404.html'
templateUrl: '/views/404.html',
title: 'Error'
});
}
]);
});
//Setting HTML5 Location Mode
angular.module('insight').config(['$locationProvider',
function($locationProvider) {
angular.module('insight')
.config(function($locationProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
}
]);
})
.run(function($rootScope, $route) {
$rootScope.$on('$routeChangeSuccess', function() {
//Change page title, based on Route information
$rootScope.titleDetail = '';
$rootScope.title = $route.current.title;
});
});

View File

@ -5,6 +5,8 @@ function($scope, $rootScope, $routeParams, $location, Global, Address, getSocket
$scope.global = Global;
$scope.findOne = function() {
$rootScope.titleDetail = $routeParams.addrStr;
Address.get({
addrStr: $routeParams.addrStr
},

View File

@ -19,6 +19,10 @@ angular.module('insight.blocks').controller('BlocksController',
$scope.list = function() {
$scope.loading = true;
if ($routeParams.blockDate) {
$rootScope.titleDetail = 'on ' + $routeParams.blockDate;
}
Blocks.get({
blockDate: $routeParams.blockDate
}, function(res) {
@ -30,6 +34,7 @@ angular.module('insight.blocks').controller('BlocksController',
$scope.findOne = function() {
$scope.loading = true;
$rootScope.titleDetail = $routeParams.blockHash;
Block.get({
blockHash: $routeParams.blockHash

View File

@ -104,11 +104,7 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
});
};
$scope.findThis = function() {
$scope.findTx($routeParams.txId);
};
$scope.findTx = function(txid) {
var _findTx = function(txid) {
Transaction.get({
txId: txid
}, function(tx) {
@ -130,6 +126,11 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
});
};
$scope.findThis = function() {
$rootScope.titleDetail = $routeParams.txId;
_findTx($routeParams.txId);
};
//Initial load
$scope.load = function(from) {
$scope.loadedBy = from;
@ -154,7 +155,7 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
$scope.txs = [];
$scope.$on('tx', function(event, txid) {
$scope.findTx(txid);
_findTx(txid);
});
});

View File

@ -2,5 +2,5 @@
angular.element(document).ready(function() {
// Init the app
angular.bootstrap(document, ['insight']);
// angular.bootstrap(document, ['insight']);
});