I'm currently building off of this: https://github.com/btford/angular-express-blog bit of code, which uses nodeJS, Express, Jade and obviously AngularJS. I'm running the most current version of AngularJS as of this post.
I'm having issues getting ng-cloak (http://docs.angularjs.org/api/ng.directive:ngCloak) to work correctly in my app. My animations and routes are working perfectly, but ng-cloak is not working for me. Anytime I animate a template switch, the template flickers/flashes in place before it animates in.
I'm pretty sure I've implemented this exactly as described in the documentation, so any insight as to what I'm doing wrong would be greatly appreciated.
Module
'use strict';
// Declare app level module which depends on filters, and services
angular.module('myApp', ['ngRoute', 'ngAnimate', 'myApp.filters', 'myApp.services', 'myApp.directives']).
config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'partials/index',
controller: IndexCtrl
}).
when('/addPost', {
templateUrl: 'partials/addPost',
controller: AddPostCtrl
}).
when('/readPost/:id', {
templateUrl: 'partials/readPost',
controller: ReadPostCtrl
}).
when('/editPost/:id', {
templateUrl: 'partials/editPost',
controller: EditPostCtrl
}).
when('/deletePost/:id', {
templateUrl: 'partials/deletePost',
controller: DeletePostCtrl
}).
otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
}]).
controller('IndexCtrl', function (
$window,
$location
){
this.switch = function() {
$location.path('/addPost' == $location.path() ? '/' : '/alt');
};
});
I have tried including ng-cloak and class="ng-cloak" inside the body tag in several ways:
body(ng-controller="IndexCtrl as main" ng-cloak class="ng-cloak")
AND I tried
body(ng-controller="IndexCtrl as main" ng-cloak)
AND I tried
body(ng-controller="IndexCtrl as main" class="ng-cloak")
I've also tried adding ng-cloak to my templates instead of including it in the body in the same combination as above:
#indexTemplate(ng-cloak class="ng-cloak")
p There are {{posts.length}} posts
div(ng-repeat='post in posts')
h3 {{post.title}}
div {{post.text}}
a(href='/readPost/{{post.id}}') More
| -
a(href='/editPost/{{post.id}}') Edit
| -
a(href='/deletePost/{{post.id}}') Delete
My index, declaring ng-view and scripts
extends layout
block body
div#index
h2 My Blog
ul
li
a(href='/') Home
li
a(href='/addPost') Add a new post
ng-view
script(src='js/lib/angular/angular.js')
script(src='js/lib/angular/angular-animate.js')
script(src='js/lib/angular/angular-route.js')
script(src='js/app.js')
script(src='js/services.js')
script(src='js/controllers.js')
script(src='js/filters.js')
script(src='js/directives.js')
CSS
ng-view {
display: block;
border: 1px dashed black;
width: 300px;
height: 300px;
position: absolute;
top: 20%;
}
.ng-enter {
-webkit-animation: enter 1s cubic-bezier(.17,.67,.83,.67);
animation: enter 1s cubic-bezier(.17,.67,.83,.67);
}
.ng-leave {
-webkit-animation: enter 1s ease-out reverse;
animation: enter 1s ease-out reverse;
}
[ng\:cloak], [ng-cloak], .ng-cloak {
display: none !important;
}
@-webkit-keyframes enter {
0% {
background: #f80;
top: 100%;
}
70% {
background: #f08;
}
100% {
background: #8f8;
top: 20%;
}
}
@keyframes enter {
0% {
background: #f80;
top: 100%;
}
70% {
background: #f08;
}
100% {
background: #8f8;
top: 20%;
}
}