Yep, I've only spent a few days on Angular and i'm working on modifying code someone else wrote.
The code is written on a platform that required a lot of hacking to get to work, so i'm not sure how i'd even start making a plunker from it. I can show you my controller and the route provider though:
Routeprovider:
ngModMain.config(['$routeProvider',
function($routeProvider, $rootScope, $scope) {
$routeProvider
.when('/home', {
templateUrl: 'demoDashboard.html',
controller: 'demoDashboardCtrl'
})
.when('/home/wall', {
templateUrl: 'demoDashboard.html',
controller: 'demoDashboardCtrl'
})
.when('/home/default', {
redirectTo: '/home'
})
//This is the one i want to have refresh as if the template had never been rendered before
.when('/expo', {
templateUrl: 'expo.html',
controller: 'atcExpoCtrl'
.otherwise({
redirectTo: '/home'
});
}
]);
Controller:
var ATCExpo = angular.module('ATCExpo', [])
//This directive broadcasts when the last ng-repeat is run for building out the impress.js slides.
.directive('initiateImpress', function($timeout, $rootScope){return {
restrict: 'A',
link: function (scope, element, attr) {
if (scope.$last === true) {
$timeout(function () {
scope.$emit('ngRepeatFinished');
});
}
}
};
});
ATCExpo.controller('atcExpoCtrl', function($scope, $timeout, $route, $rootScope, $location, $window){
//This is the logic i'm currently using to refresh the page. I feel there should be a way to do this by refreshing the template/controller and not the entire window.
$location.refresh();
// this failed to work.
//$route.reload();
}
//Event Listener for ng-repeat on Demo impress cards.This is needed because impress tries to render the cards while ng-repeat is still populating the attributes in the template.
$scope.$on('ngRepeatFinished', function() {
//if($scope.loadCount ===0){
impress().init();
//}
});
});
Template:
// the demo value here is from another script, it currently works without issue.
<div id="impress" class="impress-not-supported" name="impress">
<div ng-repeat="demo in demos" class="step top stepCSS" data-x="{{(($index + 1) * 1000) + 1000}}" data-y="{{(($index + 1) * -1500) - 1500}}" data-z="{{(($index + 1) * 2000) + 2000}}" data-rotate="180" data-scale="3" initiate-impress="">
<div class="number">
<img src="{{demo.logo}}" />
</div>
</div>