pass value from controller and view in html file - angularjs
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.
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'
Ng-route makes unwanted requests
Whenever I change a route, my app sends two unwanted GET request to the server. One fetches favicon and another one index.html file. var app = angular.module('myApp', ['ngRoute', 'ngTagsInput']); app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $locationProvider.html5Mode(true); $routeProvider.when('/', { templateUrl: 'views/profile.html', resolve: { async: ['$http', function($http) { return $http.get('/api/getUserInfo'); }], dialogs: ['$http', function($http) { return $http.get('/api/dialogs'); }] }, controller: 'ProfileController' }) .when('/friends', { template: '<div friends-directive votes="model.user.votes" friends="model.friends"></div>' }) .when('/comment', { template: '<div comment-directive></div>' }) .when('/dialogs', { template: '<div dialog-directive messages="model.messages" dialogs="model.dialogs" new-messages="model.newMessages"></div>' }) .when('/messages', { template: '<div messages-directive messages="model.messages"></div>', resolve: { async: ['$http', function($http) { return $http.get('/api/message'); }] }, controller: 'MessagesController' }) .when('/search', { template: '<div search-directive></div>' }) .when('/balance', { templateUrl: 'views/balance.html' }) .when('/users/:username', { template: '<div users-directive user-profile="model.userProfile" switcher="switcher(path)" resource="model.resource"></div>', resolve: { async: ['$http', '$route', function($http, $route) { return $http.get('/api/users/' + $route.current.params.username); }] }, controller: 'UsersController' }) .otherwise({redirectTo: '/'}); }]); app.run(['$http', '$window', function($http, $window){ var update = function(){ $http.get('/updatetime') }; setInterval(update, 60 * 1000); $window.onload = function() { update(); } }]) <base href="/"> <aside id="aside"> <div><img src="images/profile.svg"></div> <div><img src="images/users.svg"></div> <div><img src="images/search.svg"></div> <div><img src="images/database.svg"></div> <div><a ng-click="logout()"><img src="images/help.svg"></a></div> </aside> I just noticed these unwanted requests. Everything else works okay. Any idea what's going on?
FIXED: I didn't have favicon.ico file on my server. That's it!
AngularJS Toaster doesn't work with state.go
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>
angularjs ui-sref address named view
I would to make something like this: .state('tabs.order', { url: "/order/:orderId", views: { 'orders-tab': { templateUrl: "templates/orderDetail.html", controller: 'OrderDetailController' }, 'orders-all-tab': { templateUrl: "templates/orderDetail.html", controller: 'OrderDetailController' } } }) then in my view i would to put a conditional ui-sref in which i can choose the tab to be addressed; something like this: ui-sref="tabs.order({orderId:order.ID}, <orders-tab or orders-all-tab?>)" would this be possible? Thanks
Well, I don't think there is any way yet to specify the view in ui-sref, but here is a starting point which I hope it will help you.. Firstly, the routes: app.config(function($stateProvider, $urlRouterProvider){ $urlRouterProvider.otherwise("/order/all-orders"); $stateProvider .state("order", { abtract: true, url:"/order", templateUrl:"main.html" }) .state("order.orderTab", { url: "/order-details", templateUrl: "orderDetails.html" }) .state("order.orderAllTab", { url: "/all-orders", templateUrl: "allOrders.html" }); }); Then, define your main page (Orders and Order Details) [main.html] <div ng-controller="mainController"> <tabset> <tab ng-repeat="t in tabs" heading="{{t.heading}}" select="go(t.route)" active="t.active"> </tab> </tabset> <h2>View:</h2> <div ui-view></div> </div> And the page controller to specify the tab data: app.controller("mainController", function($rootScope, $scope, $state) { $scope.go = function(route){ $state.go(route); }; $scope.active = function(route){ return $state.is(route); }; $scope.tabs = [ { heading: "Order", route:"order.orderTab", active:true }, { heading: "All Orders", route:"order.orderAllTab", active:false }, ]; $scope.$on("$stateChangeSuccess", function() { $scope.tabs.forEach(function(tab) { tab.active = $scope.active(tab.route); }); }); }); All you have to do next is to include the orderID. Here is a demo
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.