Skip to content

Instantly share code, notes, and snippets.

View billrobbins's full-sized avatar

Bill Robbins billrobbins

View GitHub Profile
<router-outlet></router-outlet>
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: [ './app.component.scss' ],
animations: [fadeAnimation]
})
import { trigger, animate, transition, style, query } from '@angular/animations';
export const fadeAnimation =
trigger('fadeAnimation', [
transition( '* => *', [
query(':enter',
[
providers: [
{provide: RouteReuseStrategy, useClass: CustomReuseStrategy}
],
import { ActivatedRouteSnapshot, RouteReuseStrategy, DetachedRouteHandle } from '@angular/router';
export class CustomReuseStrategy implements RouteReuseStrategy {
shouldDetach(route: ActivatedRouteSnapshot): boolean {
return false;
}
store(route: ActivatedRouteSnapshot, handle: DetachedRouteHandle): boolean {
return false;
HTTP.get('wp-json/wp/v2/pages?slug=' + this.$route.params.id)
.then(resp => {
if (resp.data == '') {
this.$router.push('/not-found');
}
...
{
"code": "rest_post_invalid_id",
"message": "Invalid post ID.",
"data": {
"status": 404
}
}
function wpwa_legendary_enqueue_hashed_js() {
$dirJS = new DirectoryIterator(get_stylesheet_directory() . '/static/js');
foreach ($dirJS as $file) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'js') {
$fullName = basename($file);
$name = substr(basename($fullName), 0, strpos(basename($fullName), '.'));
$url = trailingslashit( get_site_url() );
wp_localize_script('app', 'baseURL', array(
'url' => $url
)
);
<script type='text/javascript'>
/* <![CDATA[ */
var baseURL = { "url": "http:\/\/legendary.test\/" };
/* ]]> */
</script>