AngularJS Toaster doesn't work with state.go - angularjs

I have a problem with this component . If I open the page directly , you see the warning. If I arrive at the page from another page do not.
ROUTER:
$stateProvider.state('login', {
url: '/login',
templateUrl: "assets/views/login.html",
resolve: loadSequence('modernizr', 'moment', 'sweet-alert', 'oitozero.ngSweetAlert', 'toaster'),
abstract: true
}).state('login.lockscreen', {
url: '/lock',
templateUrl: "assets/views/login_lock_screen.html",
title: 'Lock screen',
resolve: loadSequence('userLoginCtrl')
});
Factory for Alert:
'use strict';
app.factory("alertGenerate", ["toaster", function(toaster) {
return {
show: function(options) {
console.log("SHOW ALERT");
console.log(options);
/*
* TOASTER
*/
var config = {
type: options.type,
title: options.title,
body: options.text
};
if(options.confirmButtonText || options.showCloseButton) {
config.showCloseButton = true;
}
toaster.pop(config);
}
}
}]);
CONTROLLER:
app.controller('UserLoginCtrl', ["$rootScope", "$scope", "$auth", "$http", "$state", "$filter", "alertGenerate", function ($rootScope, $scope, $auth, $http, $state, $filter, alertGenerate) {
alertGenerate.show({
type: 'error',
title: 'Title text',
body: 'Body text',
showCloseButton: true,
closeHtml: '<button>Close</button>'
});
login.html (abstract)
<!-- toaster directive -->
<toaster-container toaster-options="{'position-class': 'toast-bottom-right', 'close-button':true}"></toaster-container>
<!-- / toaster directive -->
<div ui-view class="fade-in-right-big smooth"></div>
login_lock_screeen.html
<!-- start: LOCK SCREEN -->
<div class="row">
<div class="lock-screen">
hello
</div>
</div>

Related

ui-router loggin page without menu

I'm a begginer with angular 1.6 and I would like to do the next:
Loggin, register & remember password without menu.
After loggin: Menu, nav bar and footer appears.
Up to now I have the next:
Index.html
<ui-view></ui-view>
Loggin: Works fine.
authenticationService.Login(vm.email, vm.password, function (result) {
if (result === true) {
$location.path('/main');
} else {
vm.error = 'Username or password is incorrect.';
vm.loading = false;
}
});
};
If I have logged I go to main, here my problems appear..
<!-- Wrapper-->
<div id="wrapper">
<!-- Navigation -->
<div ng-include="'../views/partials/main-navigation.html'"></div>
<!-- Page wraper -->
<div id="page-wrapper">
<!-- Topnavbar -->
<div ng-include="'../views/partials/main-topnavbar.html'"></div>
hola mundo
<!-- Main view -->
<div ui-view>aqui tengo que meter todas las vistas</div>
<!-- Footer -->
<div ng-include="'../views/partials/main-footer.html'"></div>
</div>
<!-- End page wrapper-->
Now I would like to put the rest of my web pages inside the main
<div ui-view>All pages here</div>
How Can I do this?
I have read several pages https://ui-router.github.io/ and some more, but It is not clear for me.
I think I have to do some in my app.js but I don't now what...
(function () {
'use strict';
angular.module('frontEndApp', [
'ui.router',
'ngMessages',
'ngStorage',
'ngAnimate',
'ngAria',
'ngCookies',
'ngMessages',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ngStorage',
'ngResource',
'pascalprecht.translate']).config(config).run(run);
function config ($stateProvider, $translateProvider, $urlRouterProvider) { // default route
$urlRouterProvider.otherwise('/login');// app routes
var states = [
{ name: 'main', url: '/main', templateUrl: 'views/main/main.html' },
{ name: 'login', url: '/login', templateUrl: 'views/login/login.html', controller: 'loginController', controllerAs: 'vm' },
{ name: 'department', url: '/department', templateUrl: 'views/department/department.html', controller: 'departmentController', controllerAs: 'vm' }
];
// Loop over the state definitions and register them
states.forEach(function (state) {
$stateProvider.state(state);
});
/**
* Translation of the web page with angular-Translate
*/
$translateProvider.useStaticFilesLoader({
files: [{
prefix: '../config/languages/locale-',
suffix: '.json'
}]
});
$translateProvider.preferredLanguage('en');
$translateProvider.useSanitizeValueStrategy('escapeParameters');
}
function run ($rootScope, $http, $location, $localStorage) { // keep user logged in after page refresh
if ($localStorage.currentUser) {
$http.defaults.headers.common.Authorization = 'Bearer ' + $localStorage.currentUser.token;
}
// redirect to login page if not logged in and trying to access a restricted page
$rootScope.$on('$locationChangeStart', function (event, next, current) {
var publicPages = ['/login'];
var restrictedPage = publicPages.indexOf($location.path()) === -1;
if (restrictedPage && !$localStorage.currentUser) {
$location.path('/login');
}
});
}
})();
Thanks in advance for your help.
Simply:
{ name: 'main', url: '/main', templateUrl: 'views/main/main.html' },
{ name: 'login', url: '/login', templateUrl: 'views/login/login.html',
controller: 'loginController', controllerAs: 'vm' },
{ name: 'main.department', url: '/department', templateUrl:
'views/department/department.html', controller: 'departmentController',
controllerAs: 'vm' }
If department belongs to main then call it: 'main.department'

how to create composite route in $stateProvider

If I go to /settings/wizard/hv then I see only Settings Page. what am I doing wrong?
I have Page: "Settings" url: '/settings'
on page button.handler > go to url: '/settings/wizard'
I have this code:
$stateProvider
.state('settings', {
url: '/settings',
template: '<div>Settings panel with fields</div>',
title: 'Конфигурация',
controller: function(){
console.log('controller settings')
}
})
.state('settings.wizard', {
url: '/wizard',
abstract: true,
template: '<ui-view></ui-view>',
title: 'Мастер настройки',
/** #ngInject */
controller: function($state, $scope, $controller){
console.log('controller Wizard');
if($scope.mode == 'vw'){
$state.go('settings.wizard.vw')
}else{
$state.transitionTo('settings.wizard.hv')
}
}
})
.state('settings.wizard.hv', {
url: '/hv',
parent: 'settings.wizard',
templateUrl: 'app/plugins/settings/wizard/tpl/wizard.html',
title: 'Мастер настройки',
/** #ngInject */
controller: function ($controller, $scope) {
console.log('controller wizard/hv')
$scope.mode = 'hv';
var ctrl = $controller('Settings.Wizard');
ctrl.setMode('hv');
},
controllerAs: 'wizard'
})
.state('settings.wizard.vw', {
url: '/vw',
// parent: 'settings.wizard',
templateUrl: 'app/plugins/settings/wizard/tpl/wizard.html',
title: 'Мастер настройки',
/** #ngInject */
controller: function ($controller, $scope) {
console.log('controller wizard/vw')
$scope.mode = 'hv';
var ctrl = $controller('Settings.Wizard');
ctrl.setMode('vw');
},
controllerAs: 'wizard'
});
on Page '/settings/wizard/hv' I have some subPages and Views
<div>
settings > wizard > hv
<input />
<ui-view></ui-view>
<button onclick="$state.go('settings.wizard.hv.servers')" >go to servers</button>
</div>
First of all, try to add ui-view to your settings state template:
$stateProvider
.state('settings', {
url: '/settings',
template: '<section><div>Settings panel with fields</div><div ui-view></div></section>',
title: 'Конфигурация',
controller: function(){
console.log('controller settings')
}
})
Child states requires a spot to render into.

Angular ui-route base controller extend

I'm really lost. I use ui-route in my angular app and i'm trying to extend my base controller. My base controller (appCtrl) works but child controller (navigationCtrl) doesn't on URL app/welcome. Do you know why???
index.html
<body>
<div id="wrap">
<!-- View for login and login-choose -->
<div ui-view="login"></div>
<!-- View for app -->
<div ui-view="app"></div>
</div>
<!-- SCRIPTS -->
<script type="text/javascript" src="./js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="./js/jasny-bootstrap.min.js"></script>
<script type="text/javascript" src="./js/angular.min.js"></script>
<script type="text/javascript" src="./js/angular-ui-router.min.js"></script>
<script type="text/javascript" src="./js/angular-touch.min.js"></script>
<script type="text/javascript" src="./js/app.js"></script>
<script type="text/javascript" src="./js/app.navigation.js"></script>
</body>
app.js
var app = angular.module('tvm', ['ui.router', 'ngTouch']);
app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/");
// Set up the states
$stateProvider
.state('login', {
url: "/",
views: {
"login": { templateUrl: "./pages/login.html" }
}
})
.state('login-choose', {
url: "/login-choose",
views: {
"login": { templateUrl: "./pages/login-choose.html" }
}
})
.state('app', {
url: "/app",
views: {
"app": {
templateUrl: "app.html",
controller: 'appCtrl'
}
}
})
.state('app.welcome', {
url: "/welcome",
templateUrl: './pages/welcome.html'
})
.state('app.profile', {
url: "/profile",
templateUrl: './pages/profile.html'
});
// remove # from URL
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
app.controller('appCtrl', function($scope) {
$scope.parentMethod = function () {
alert('aaa');
};
});
app.navigation.js
app.controller('navigationCtrl', ['$scope', '$controller', function($scope, $controller) {
// extend app controller
angular.extend(this, $controller('appCtrl', {$scope: $scope}));
var nav = $('nav');
var content = $('#content, #bar');
var navWidth = nav.width() + 'px';
var navIcon = $('#bar .nav_icon .circle');
$scope.circleHover = function(e) {
navIcon.addClass('hover');
};
$scope.circleLeave = function(e) {
navIcon.removeClass('hover');
};
// open / close nav
$scope.toggleNav = function(e) {
if(nav.hasClass('visible'))
closeNav();
else
openNav();
};
// when swipe left to right open nav
$scope.openSwipeNav = function(e) {
openNav();
};
// close nav
$scope.closeNav = function(e) {
var elem = angular.element(e.target);
if( (nav.hasClass('visible')) && (!$(elem).is('#bar')) )
closeNav();
};
// when swipe right to left close nav
$scope.closeSwipeNav = function(e) {
closeNav();
};
var openNav = function() {
nav.animate({
left: 0
}, 400, function() {
$(this).addClass('visible');
});
content.animate({
left: navWidth
}, 400, function() {
$(this).removeClass('full');
});
navIcon.addClass('active');
};
var closeNav = function() {
nav.animate({
left: '-' + navWidth
}, 400, function() {
$(this).removeClass('visible');
});
content.animate({
left: 0
}, 400, function() {
$(this).addClass('full');
navIcon.removeClass('active');
navIcon.removeClass('hover');
});
};
}]);
You are providing the states in wrong way should use the below code. It may help you get out of your problem
// Set up the states
$stateProvider
.state('login', {
url: "/",
views: {
"login": { templateUrl: "./pages/login.html" }
}
})
.state('login-choose', {
url: "/login-choose",
views: {
"login": { templateUrl: "./pages/login-choose.html" }
}
})
.state('app', {
url: "/app",
templateUrl: "app.html" //no need to define the controller here. If this route is not usable else define the controller separately for both app and app.welcome
})
.state('app.welcome', {
url: "/welcome",
templateUrl: './pages/welcome.html',
controller: 'appCtrl' // need to mention the controller in which you wantto perform the functionality of app/welcome
})
.state('app.profile', {
url: "/profile",
templateUrl: './pages/profile.html'
});
Ok I managed to solve it by add angular.extend to base controller
app.controller('appCtrl', ['$scope', '$controller', function($scope, $controller) {
angular.extend(this, $controller('navigationCtrl', {$scope: $scope}));
}]);
And I call controller in my first state:
.state('app', {
url: "/app",
views: {
"app": {
templateUrl: "app.html",
controller: 'appCtrl'
}
}
})
Then it also fires navigationCtrl

pass value from controller and view in html file

I am trying to pass value from controller and show it in html file using angularjs but unable to achieve it. I am using metronic angularjs theme and implementing easypie charts on dashboard and want to pass value to that using controller.
This is app.js file:
var MetronicApp = angular.module("MetronicApp", [
"ui.router",
"ui.bootstrap",
"oc.lazyLoad",
"ngSanitize",
'ngCookies'
]);
MetronicApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
});
MetronicApp.config(function($httpProvider) {
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
});
/* Configure ocLazyLoader(refer: https://github.com/ocombe/ocLazyLoad) */
MetronicApp.config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {
$ocLazyLoadProvider.config({
cssFilesInsertBefore: 'ng_load_plugins_before' // load the above css files before a LINK element with this ID. Dynamic CSS files must be loaded between core and theme css files
});
}]);
/********************************************
BEGIN: BREAKING CHANGE in AngularJS v1.3.x:
*********************************************/
/**
`$controller` will no longer look for controllers on `window`.
The old behavior of looking on `window` for controllers was originally intended
for use in examples, demos, and toy apps. We found that allowing global controller
functions encouraged poor practices, so we resolved to disable this behavior by
default.
To migrate, register your controllers with modules rather than exposing them
as globals:
Before:
```javascript
function MyController() {
// ...
}
```
After:
```javascript
angular.module('myApp', []).controller('MyController', [function() {
// ...
}]);
Although it's not recommended, you can re-enable the old behavior like this:
```javascript
angular.module('myModule').config(['$controllerProvider', function($controllerProvider) {
// this option might be handy for migrating old apps, but please don't use it
// in new ones!
$controllerProvider.allowGlobals();
}]);
**/
MetronicApp.factory('authInterceptor', ['$q', '$window', '$injector', function($q, $window, $injector) {
return {
request: function(config) {
config.headers = config.headers || {};
if ($window.localStorage.token) {
config.headers.Authorization = 'Bearer ' + $window.localStorage.token;
}
return config;
},
response: function(response) {
if (response.status === 401) {
// handle the case where the user is not authenticated
}
return response || $q.when(response);
},
responseError: function(rejection) {
if (rejection.status == 401) {
var $state = $injector.get("$state");
$state.go('login')
// location.reload();
}
return $q.reject(rejection);
}
};
}]);
MetronicApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.interceptors.push('authInterceptor');
}]);
//AngularJS v1.3.x workaround for old style controller declarition in HTML
MetronicApp.config(['$controllerProvider', function($controllerProvider) {
// this option might be handy for migrating old apps, but please don't use it
// in new ones!
$controllerProvider.allowGlobals();
}]);
/********************************************
END: BREAKING CHANGE in AngularJS v1.3.x:
*********************************************/
/* Setup App Main Controller */
MetronicApp.controller('AppController', ['$scope', '$rootScope', function($scope, $rootScope) {
$scope.$on('$viewContentLoaded', function() {
Metronic.initComponents(); // init core components
//Layout.init(); // Init entire layout(header, footer, sidebar, etc) on page load if the partials included in server side instead of loading with ng-include directive
});
}]);
/***
Layout Partials.
By default the partials are loaded through AngularJS ng-include directive. In case they loaded in server side(e.g: PHP include function) then below partial
initialization can be disabled and Layout.init() should be called on page load complete as explained above.
***/
/* Setup Layout Part - Header */
MetronicApp.controller('HeaderController', ['$scope', function($scope) {
$scope.$on('$includeContentLoaded', function() {
Layout.initHeader(); // init header
});
}]);
/* Setup Layout Part - Sidebar */
MetronicApp.controller('SidebarController', ['$scope', function($scope) {
$scope.$on('$includeContentLoaded', function() {
Layout.initSidebar(); // init sidebar
});
}]);
/* Setup Layout Part - Sideba
r */
MetronicApp.controller('PageHeadController', ['$scope', function($scope) {
$scope.$on('$includeContentLoaded', function() {
Demo.init(); // init theme panel
});
}]);
/* Setup Layout Part - Footer */
MetronicApp.controller('FooterController', ['$scope', function($scope) {
$scope.$on('$includeContentLoaded', function() {
Layout.initFooter(); // init footer
});
}]);
/* Setup Rounting For All Pages */
MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
// Redirect any unmatched url
$urlRouterProvider
.otherwise(function($injector, $location) {
// This function prevents the infinite loop on otherwise while session wasn't found
var $state = $injector.get("$state");
$state.go("home");
});
$stateProvider
.state('app', {
url: "/app/",
templateUrl: "static/html/tpl/app.html"
})
// Dashboard
.state('app.dashboard', {
url: "dashboard",
templateUrl: "static/html/views/dashboard.html",
data: {
pageTitle: 'Dashboard'
// pageSubTitle: 'statistics & reports'
},
requireLogin: true,
controller: "DashboardController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_before', // load the above css files before '#ng_load_plugins_before'
files: [
'static/assets/global/plugins/morris/morris.css',
'static/assets/admin/pages/css/tasks.css',
'static/assets/global/plugins/morris/morris.min.js',
'static/assets/global/plugins/morris/raphael-min.js',
'static/assets/global/plugins/angularjs/angular.min.js',
'static/assets/global/plugins/jquery-easypiechart/jquery.easypiechart.min.js',
'static/assets/global/plugins/jquery.sparkline.min.js',
'static/assets/admin/pages/scripts/index3.js',
'static/assets/admin/pages/scripts/tasks.js',
'static/js/controllers/DashboardController.js'
]
});
}]
}
})
.state('home', {
url: "/login",
templateUrl: "static/html/views/login.html",
controller: "LoginController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_before',
files: [
'static/assets/admin/pages/css/login-soft.css',
'static/assets/global/plugins/bootstrap/css/bootstrap.min.css',
'static/assets/global/plugins/jquery.min.js',
'static/assets/global/plugins/bootstrap/js/bootstrap.min.js',
'static/assets/global/plugins/backstretch/jquery.backstretch.min.js',
'static/assets/admin/pages/scripts/login-soft.js',
'static/js/controllers/AccessController.js',
'static/js/services/AccessService.js',
'static/js/services/CommonService.js'
]
}]);
}]
}
})
// .state('home', {
// url: "/home",
// // controller:"HomeController"
// templateUrl: "views/home.html",
// resolve: {
// deps: ['$ocLazyLoad', function($ocLazyLoad) {
// return $ocLazyLoad.load([{
// name: 'MetronicApp',
// files: [
// 'js/controllers/HomeController.js'
// ]
// }]);
// }]
// }
// })
// .state('login', {
// url: "/login",
// templateUrl: "views/login.html",
// controller: "LoginController",
// resolve: {
// deps: ['$ocLazyLoad', function($ocLazyLoad) {
// return $ocLazyLoad.load([{
// name: 'MetronicApp',
// insertBefore: '#ng_load_plugins_before',
// files: [
// '../assets/admin/pages/css/login-soft.css',
// '../assets/global/plugins/bootstrap/css/bootstrap.min.css',
// '../assets/global/plugins/jquery.min.js',
// '../assets/global/plugins/bootstrap/js/bootstrap.min.js',
// '../assets/global/plugins/backstretch/jquery.backstretch.min.js',
// '../assets/admin/pages/scripts/login-soft.js',
// 'js/controllers/AccessController.js',
// 'js/services/AccessService.js',
// 'js/services/CommonService.js'
// ]
// }]);
// }]
// }
// })
.state('signup', {
url: "/signup",
templateUrl: "static/html/views/signup.html",
controller: "SignupController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_before',
files: [
'static/assets/admin/pages/css/login-soft.css',
'static/assets/global/plugins/bootstrap/css/bootstrap.min.css',
'static/assets/global/plugins/jquery.min.js',
'static/assets/global/plugins/bootstrap/js/bootstrap.min.js',
'static/assets/global/plugins/backstretch/jquery.backstretch.min.js',
'static/assets/admin/pages/scripts/login-soft.js',
'static/js/controllers/AccessController.js',
'static/js/services/AccessService.js',
'static/js/services/CommonService.js'
]
}]);
}]
}
})
.state('forget-password', {
url: "/forget-password",
templateUrl: "static/html/views/forget-password.html",
controller: "ForgetPasswordController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_before',
files: [
'static/assets/admin/pages/css/login-soft.css',
'static/assets/global/plugins/bootstrap/css/bootstrap.min.css',
'static/assets/global/plugins/jquery.min.js',
'static/assets/global/plugins/bootstrap/js/bootstrap.min.js',
'static/assets/global/plugins/backstretch/jquery.backstretch.min.js',
'static/assets/admin/pages/scripts/login-soft.js',
'static/js/controllers/AccessController.js',
'static/js/services/AccessService.js',
'static/js/services/CommonService.js'
]
}]);
}]
}
})
// AngularJS plugins
.state('fileupload', {
url: "/file_upload.html",
templateUrl: "static/html/views/file_upload.html",
data: {
pageTitle: 'AngularJS File Upload',
pageSubTitle: 'angularjs file upload'
},
controller: "GeneralPageController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'angularFileUpload',
files: [
'static/assets/global/plugins/angularjs/plugins/angular-file-upload/angular-file-upload.min.js',
]
}, {
name: 'MetronicApp',
files: [
'static/js/controllers/GeneralPageController.js'
]
}]);
}]
}
})
// UI Select
.state('uiselect', {
url: "/ui_select.html",
templateUrl: "static/html/views/ui_select.html",
data: {
pageTitle: 'AngularJS Ui Select',
pageSubTitle: 'select2 written in angularjs'
},
controller: "UISelectController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load([{
name: 'ui.select',
insertBefore: '#ng_load_plugins_before', // load the above css files before '#ng_load_plugins_before'
files: [
'static/assets/global/plugins/angularjs/plugins/ui-select/select.min.css',
'static/assets/global/plugins/angularjs/plugins/ui-select/select.min.js'
]
}, {
name: 'MetronicApp',
files: [
'static/js/controllers/UISelectController.js'
]
}]);
}]
}
})
}]);
/* Init global settings and run the app */
MetronicApp
.service('AuthenticateService', ['$http', '$cookieStore', '$window', function($http, $cookieStore, $window) {
this.isLoggedIn = function() {
if (!$cookieStore.get('JU_user_logged') || $cookieStore.get('JU_user_logged') == false || !$window.localStorage.token) {
return false;
} else {
return true;
};
};
}])
.run(['$rootScope', '$state', '$stateParams', 'AuthenticateService', '$window',
function($rootScope, $state, $stateParams, AuthenticateService, $window) {
$rootScope.$state = $state;
$rootScope.$on('$stateChangeStart', function(event, toState) {
if (toState.name != 'login' && !AuthenticateService.isLoggedIn() && toState.requireLogin) {
$state.go('login');
event.preventDefault();
return;
}
});
}
])
This is my DashboardController through which I want to pass value:-
'use strict';
MetronicApp.controller('DashboardController', function($rootScope, $scope, $http, $timeout) {
$scope.$on('$viewContentLoaded', function() {
// initialize core components
Metronic.initAjax();
});
$scope.steps = 1000;
});
This is the dashboard.html file:-
<ul class="page-breadcrumb breadcrumb hide">
<li>
Home<i class="fa fa-circle"></i>
</li>
<li class="active">
Dashboard
</li>
</ul>
<div ng-controller="DashboardController" class="margin-top-10">
<h1>**{{ steps }}** </h1>
<div class="row ">
<div class="col-md-12 col-sm-12">
<div class="portlet light ">
<div class="portlet-title">
<div class="caption">
<i class="icon-cursor font-purple-intense hide"></i>
<span class="caption-subject font-purple-intense bold uppercase">Tracker Report</span>
</div>
<div class="actions">
<a href="javascript:;" class="btn btn-sm btn-circle btn-default easy-pie-chart-reload">
<i class="fa fa-repeat"></i> Reload </a>
</div>
</div>
<div class="portlet-body">
<div class="row">
<div class="col-md-3">
<div class="easy-pie-chart">
<div class="number transactions" data-percent="55">
<span>{{ steps }}</span>
</div>
</a>
</div>
</div>
<div class="margin-bottom-10 visible-sm">
</div>
<div class="col-md-3">
<div class="easy-pie-chart">
<div class="number visits" data-percent="85">
<span>
+85 </span>
%
</div>
</a>
</div>
</div>
<div class="margin-bottom-10 visible-sm">
</div>
<div class="col-md-3">
<div class="easy-pie-chart">
<div class="number bounce" data-percent="46">
<span>
+46 </span>
%
</div>
</a>
</div>
</div>
<div class="margin-bottom-10 visible-sm">
</div>
<div class="col-md-3">
<div class="easy-pie-chart">
<div class="number bounce" data-percent="32">
<span>
+32 </span>
%
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You've changed the interpolate symbol in your app.js file:
MetronicApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
});
It means that ,in your templates, you need to replace:
<h1>**{{ steps }}** </h1>
to
<h1>**{$ steps $}** </h1>
Or to remove the lines in your app.js file to keep the default interpolate symbol.

Angular-Translate Partial loader isn't working

I'm using AngularJS translate, and If I use it as says the tutorial from pascalprecht my angular app fail and it doesn't show anything (it doesn't load partial views), so I decided to use angular-translate-partial-loader
I have one app menu, and I have a MenuCtrl to display options, I want to translate this menu
Here Is my code
angular.module('myapp'['ngAnimate','ngAria','ngCookies','ngMessages','ngResource','ngRoute','ngSanitize', 'ngTouch', 'pascalprecht.translate'])
.value('language', 'bra')
.run(function ($rootScope, $translate)
{
$rootScope.$on('$translatePartialLoaderStructureChanged', function ()
{
$translate.refresh();
}
);
})
.config(function($translateProvider, $translatePartialLoaderProvider) {
$translateProvider.useLoader('$translatePartialLoader', {
urlTemplate: 'translations/{lang}/{part}.json'
});
$translateProvider.preferredLanguage("bra");
})
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl'
})
.otherwise({
redirectTo: '/'
});
});
angular.module('myapp')
.controller('MenuCtrl', function ($scope, $translatePartialLoader) {
$translatePartialLoader.addPart('menu');
$scope.lItems = [
{
title: "HOME",
class:'active',
href:'/',
visible: true
},
{
title: "CLASSROOMS",
class:'',
href:'#',
visible: true
},
{
title: "EXPENSES",
class:'',
href:'#',
visible: true
},
{
title: "EARNINGS",
class:'',
href:'#',
visible: true
},
{
title: "STUDENTS",
class:'',
href:'#',
visible: true
}
];
});
In index.html
<div id="navbar" class="navbar-collapse collapse" ng-controller="MenuCtrl">
<ul class="nav navbar-nav" ng-repeat="lItem in lItems">
<li class="{{lItem.class}}">{{lItem.title | translate}}</li>
</ul>
</div>
Can you help me?
Thanks!
Finally I found the solution.
The trouble was that the menu is out of ng-view block, and when the app loads doesn't refresh the correct html part.
By adding this $translatePartialLoaderProvider.addPart('menu');
.config(function ($translateProvider, $translatePartialLoaderProvider) {
$translatePartialLoaderProvider.addPart('menu');
$translateProvider.useLoader('$translatePartialLoader', {
urlTemplate: 'translations/{lang}/{part}.json'
});
$translateProvider.preferredLanguage('bra');
....
When the application loads the menu part is also loaded.

Resources