Angular - *ngFor and MEAN App - angularjs

I have a mean app running succesfully and I am at the stage of adding UIkit to style the application. Having some trouble with the ngFor and rendering the correct elements on the page.
So here is the code for the layout sans backend code.
<!DOCTYPE html>
<html>
<head>
<title>Home Automation | Adam Sackfield</title>
<link rel="stylesheet" href="css/uikit.min.css" />
<link rel="stylesheet" href="css/style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="js/uikit.min.js"></script>
</head>
<body>
<nav class="uk-navbar-container" uk-navbar uk-sticky>
<div class="uk-navbar-left">
<a class="uk-navbar-item uk-logo" href="">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="34" viewBox="0 0 28 34" class="uk-margin-small-right uk-svg" ratio="1">
<polygon fill="#fff" points="19.1,4.1 13.75,1 8.17,4.45 13.6,7.44 "></polygon>
<path fill="#fff" d="M21.67,5.43l-5.53,3.34l6.26,3.63v9.52l-8.44,4.76L5.6,21.93v-7.38L0,11.7v13.51l13.75,8.08L28,25.21V9.07 L21.67,5.43z"></path>
</svg> Home Automation
</a>
</div>
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">
<li class="uk-active">Control Centre</li>
<li class="uk-parent">About</li>
<li>Contact</li>
</ul>
</div>
</nav>
<div class="uk-container">
<h1 class="uk-h1 uk-text-center">Control Centre</h1>
<ul class="uk-tab uk-margin-auto" uk-switcher>
<li>Sensors</li>
<li>Devices</li>
<li>Admin</li>
</ul>
<ul class="uk-switcher animation: uk-animation-fade">
<li>
<hr class="uk-divider-icon">
<div class="uk-child-width-expand#s uk-text-center" uk-grid>
<div>
<div class="uk-card uk-card-secondary uk-card-hover uk-card-body uk-transform-origin-bottom-right uk-animation-scale-up">
<h2 class="uk-h2">Lounge Light</h2>
<button class="uk-button uk-button-default">On</button> <!-- In final app add: ng-disabled="!device.onStatus" -->
<button class="uk-button uk-button-default switchOff" disabled>Off</button> <!-- In final app add: ng-disabled="device.onStatus" -->
</div>
</div>
<div>
<div class="uk-card uk-card-secondary uk-card-hover uk-card-body uk-transform-origin-bottom-right uk-animation-scale-up">
<h2 class="uk-h2">Kitchen Light</h2>
<button class="uk-button uk-button-default" disabled>On</button> <!-- In final app add: ng-disabled="!device.onStatus" -->
<button class="uk-button uk-button-default switchOff">Off</button> <!-- In final app add: ng-disabled="device.onStatus" -->
</div>
</div>
<div>
<div class="uk-card uk-card-secondary uk-card-hover uk-card-body uk-transform-origin-bottom-right uk-animation-scale-up">
<h2 class="uk-h2">Bedroom Light</h2>
<button class="uk-button uk-button-default">On</button> <!-- In final app add: ng-disabled="!device.onStatus" -->
<button class="uk-button uk-button-default switchOff" disabled>Off</button> <!-- In final app add: ng-disabled="device.onStatus" -->
</div>
</div>
</div>
</li>
<li>Hello again!</li>
<li>Bazinga!</li>
</ul>
</div>
</body>
</html>
Here is the code for the Mean app with the *ngFor
<div class="uk-container">
<h1 class="uk-h1 uk-text-center">Control Centre</h1>
<ul class="uk-tab uk-margin-auto" uk-switcher>
<li>Sensors</li>
<li>Devices</li>
<li>Admin</li>
</ul>
<ul class="uk-switcher animation: uk-animation-fade">
<li>
<hr class="uk-divider-icon">
<div *ngFor="let device of devices" class="uk-child-width-expand#s uk-text-center" uk-grid>
<div>
<div class="uk-card uk-card-secondary uk-card-hover uk-card-body uk-transform-origin-bottom-right uk-animation-scale-up">
<h2 class="uk-h2">{{ device.name }}</h2>
<button class="uk-button uk-button-default">On</button> <!-- In final app add: ng-disabled="!device.onStatus" -->
<button class="uk-button uk-button-default switchOff" disabled>Off</button> <!-- In final app add: ng-disabled="device.onStatus" -->
</div>
</div>
</div>
</li>
<li>Hello again!</li>
<li>Bazinga!</li>
</ul>
</div>
Screenshot of rendered views imgur
Notice inside the views the class "uk-first-column" is added on each iteration (although not sure if this is the problem). Any pointers would be greatly appreciated. As you can see from the screenshots on the ngFor each device is full width whereas on the simple UIkit version they are split in to 3 columns.

Related

Undefined variable in app.blade.php laravel5.4

i want to list the name of courses from my database in my navbar menu (app view) :
#foreach ($cours as $cour)
<li><a class="dropdown-item">{{ $cour->nom }}</a></li>
#endforeach
and i created my layoutcontroller to display the view :
class layoutController extends Controller
{
public function showView()
{
$cours = DB::table('cours')->select('id','nom')->get();
return view('app',['cours' => $cours]);
}
}
then i made a route for it :
Route::get('#','layoutController#showView');
the problem is when i navigate to login view for exemple it shows an error that the variable cours is undefined in my app layout view :
Undefined variable: cours (View: C:\wamp64\www\opencourses\resources\views\layouts\app.blade.php) (View: C:\wamp64\www\opencourses\resources\views\layouts\app.blade.php)
here is my login view :
#extends('layouts.app')
#section('content')
<div class="container-fluid">
<div class="row">
<div class="col-md-8 offset-md-2 px-3 py-3 pt-md-4 pb-md-4">
<div class="card">
<div class="card-header">Connexion</div>
<div class="card-body">
<form class="form-horizontal" method="POST">
{{ csrf_field() }}
<div class="row mb-3">
<label for="email" class="col-sm-3 offset-sm-1 col-form-label">Adresse Email</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="email" name="email">
</div>
</div>
<div class="row mb-3">
<label for="password" class="col-sm-3 offset-sm-1 col-form-label">Mot de passe</label>
<div class="col-sm-7">
<input type="password" class="form-control" id="password" name="password">
</div>
</div>
<div class="row mb-3">
<div class="offset-sm-4 col-sm-7">
<button type="submit" class="btn btn-primary">Envoyer</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
#endsection
and here is my app view :
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<title>Mon blog</title>
<link rel="icon" href="https://www.jsdelivr.com/img/icon_256x256.png">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/css/bootstrap.min.css">
<!-- other CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/css/flag-icon.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/font-awesome#4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- Bootstrap javascript -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-light p-3 px-md-4 mb-3 bg-body border-bottom shadow-sm">
<div class="container-fluid">
<a class="navbar-brand" href="welcome.html">
<img src="https://www.jsdelivr.com/img/icon_256x256.png" width="30" height="30" class="d-inline-block align-top" alt=""> Mon blog
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 d-flex">
<li class="nav-item px-2">
<a class="nav-link active" aria-current="page" href="<?php echo url('')?>">Accueil</a>
</li>
<li class="nav-item dropdown px-2">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Articles
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
#foreach ($cours as $cour)
<li><a class="dropdown-item">{{ $cour->nom }}</a></li>
#endforeach
</ul>
</li>
<!-- si utilisateur non authentifié -->
#guest
<li class="nav-item px-2">
<a class="btn btn-outline-primary me-2" href="<?php echo url('login')?>">Connexion</a>
</li>
<li class="nav-item px-2">
<a class="btn btn-primary" href="<?php echo url('register')?>">S'inscrire</a>
</li>
#else
<!-- si utilisateur authentifié -->
<li class="nav-item px-2">
<a class="nav-link" href="home">Mon compte</a>
</li>
<li class="nav-item px-2">
<a class="nav-link" href="{{ route('logout') }}" onclick="event.preventDefault();
document.getElementById('logout-form').submit();">Déconnexion</a>
</li>
#endguest
</ul>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</div>
</div>
</nav>
#yield('content')
<footer class="container pt-4 my-md-5 pt-md-5 border-top">
<div class="row">
<div class="col-12 col-md">
<img class="mb-2" src="https://www.jsdelivr.com/img/icon_256x256.png" alt="" width="24" height="24">
<small class="d-block mb-3 text-muted">© 2017–2021</small>
</div>
<div class="col-6 col-md">
<h5>Features</h5>
<ul class="list-unstyled text-small">
<li><a class="link-secondary" href="#">Team feature</a></li>
<li><a class="link-secondary" href="#">Stuff for developers</a></li>
<li><a class="link-secondary" href="#">Another one</a></li>
<li><a class="link-secondary" href="#">Last time</a></li>
</ul>
</div>
<div class="col-6 col-md">
<h5>Resources</h5>
<ul class="list-unstyled text-small">
<li><a class="link-secondary" href="#">Resource name</a></li>
<li><a class="link-secondary" href="#">Another resource</a></li>
</ul>
</div>
<div class="col-6 col-md">
<h5>About</h5>
<ul class="list-unstyled text-small">
<li><a class="link-secondary" href="#">Privacy</a></li>
<li><a class="link-secondary" href="#">Terms</a></li>
</ul>
</div>
</div>
</footer>
</body>
</html>
In your existing action you've sent $cours variable only for login view blade. In this kind of situations you can use share() method via "View" facade. This will allow you to share the variable to all your blades (which includes your whole layout blade).
// don't forget to include this class in the top
use Illuminate\Support\Facades\View;
public function showView()
{
$cours = DB::table('cours')->select('id','nom')->get();
View::share('action', $action);
return view('login'); // here not need to pass shared variable
}
In other words, with this you can increase the visibility scope of your sent variables.
I use model class to get data from DB. I hope this will help for you,
class Course extends Model
{
//
protected $table = 'cours';
protected $fillable = array('nom');
}
class LayoutController extends Controller
{
public function showView()
{
$cours = Course::select('id','nom')->get();
$data['cours'] = $cours;
return view('app', $data);
}
}

Angular Slider code not changing slides

I am using a bootstrap slider using the HTML code and CSS.
BUt the slides are not changing automatically or manually.
below is the code of slider.
(function( $ ) {
//Function to animate slider captions
function doAnimations( elems ) {
//Cache the animationend event in a variable
var animEndEv = 'webkitAnimationEnd animationend';
elems.each(function () {
var $this = $(this),
$animationType = $this.data('animation');
$this.addClass($animationType).one(animEndEv, function () {
$this.removeClass($animationType);
});
});
}
//Variables on page load
var $myCarousel = $('#carousel-example-generic'),
$firstAnimatingElems = $myCarousel.find('.item:first').find("[data-animation ^= 'animated']");
//Initialize carousel
$myCarousel.carousel();
//Animate captions in first slide on page load
doAnimations($firstAnimatingElems);
//Pause carousel
$myCarousel.carousel('pause');
//Other slides to be animated on carousel slide event
$myCarousel.on('slide.bs.carousel', function (e) {
var $animatingElems = $(e.relatedTarget).find("[data-animation ^= 'animated']");
doAnimations($animatingElems);
});
$('#carousel-example-generic').carousel({
interval:3000,
pause: "false"
});
})(jQuery);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/animate.css/3.5.1/animate.min.css">
<div id="first-slider">
<div id="carousel-example-generic" class="carousel slide carousel-fade">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<!-- Item 1 -->
<div class="item active slide1">
<div class="row">
<div class="container">
<div class="col-md-3 text-right">
<img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/pfmmo6qj1/window_domain.png">
</div>
<div class="col-md-9 text-left">
<h3 data-animation="animated bounceInDown">Add images, or even your logo!</h3>
<h4 data-animation="animated bounceInUp">Easily use stunning effects</h4>
</div>
</div>
</div>
</div>
<!-- Item 2 -->
<div class="item slide2">
<div class="row">
<div class="container">
<div class="col-md-7 text-left">
<h3 data-animation="animated bounceInDown"> 50 animation options A beautiful</h3>
<h4 data-animation="animated bounceInUp">Create beautiful slideshows </h4>
</div>
<div class="col-md-5 text-right">
<img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/sp11uneml/rack_server_unlock.png">
</div>
</div>
</div>
</div>
<!-- Item 3 -->
<div class="item slide3">
<div class="row">
<div class="container">
<div class="col-md-7 text-left">
<h3 data-animation="animated bounceInDown">Simple Bootstrap Carousel</h3>
<h4 data-animation="animated bounceInUp">Bootstrap Image Carousel Slider with Animate.css</h4>
</div>
<div class="col-md-5 text-right">
<img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/eq8xvxeq5/globe_network.png">
</div>
</div>
</div>
</div>
<!-- Item 4 -->
<div class="item slide4">
<div class="row">
<div class="container">
<div class="col-md-7 text-left">
<h3 data-animation="animated bounceInDown">We are creative</h3>
<h4 data-animation="animated bounceInUp">Get start your next awesome project</h4>
</div>
<div class="col-md-5 text-right">
<img style="max-width: 200px;" data-animation="animated zoomInLeft" src="http://s20.postimg.org/9vf8xngel/internet_speed.png">
</div>
</div>
</div>
</div>
<!-- End Item 4 -->
</div>
<!-- End Wrapper for slides-->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<i class="fa fa-angle-left"></i>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<i class="fa fa-angle-right"></i>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!doctype html>
<html ng-app="plunker" >
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"> </script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"> </script>
<script src="app.js"></script>
<!-- adding css files -->
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<div class="container" ng-controller="CarouselCtrl">
<div class="offsetspan6">
<carousel interval="myInterval">
<slide ng-repeat="slide in slides" active="slide.active">
<img class="image-circle" ng-src="{{slide.image}}" style="margin:auto;"/>
<div class="carousel-caption">
<h4>Slide {{$index}}</h4>
<p>{{slide.text}}</p>
</div>
</slide>
</carousel>
</div>
</div>
</div>
</body>
<script type="text/javascript">
//angular.module('myApp', ['ui.bootstrap']);
var app = angular.module('plunker', ['ui.bootstrap']);
// Controller for Carousel
function CarouselCtrl($scope) {
// initializing the time Interval
$scope.myInterval = 1000;
// Initializing slide rray
$scope.slides = [
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Platy%20PIX/Xiphophorus%20maculatusAQ%20Neon%20female.jpg',text:'Cute Fish'},
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Platy%20PIX/Xiphophorus%20maculatusAQ%20Neon%20female.jpg',text:'Image2'},
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Swordtail%20PIX/Xiphophorus%20helleriAQ%20Hifin%20Black%20males.jpg',text:'Image3'},
{image:'http://www.wetwebmedia.com/fwsubwebindex/Cyprinodontiform%20PIX/Platy%20PIX/Xiphophorus%20maculatusAQ%20Neon%20female.jpg',text:'Image4'}
];
var slides = $scope.slides;
console.log(slides);
} // Controller Ends here
</script>
</html>

How to put a small angularjs app on my codepen

I try to upload a small angularjs app to my code pen. My question is: how to put the views?
I have two views. So they're in two separate .html files. But on code pen you have only one .html placeholder.
What I tried to do, is to put them in a tag with id, but it's doesn't work.
Here's the code:
<!-- html templates used by angular, usually in separate files -->
<script type="text/ng-template" id="albumDetails.html">
<div>
<ul>
<li ng-repeat="albumDetails in albumDetails | searchFor:searchString">
<div class="d-flex flex-row">
<div class="p-2"><img src="img/photo_album.png" class="albumIcon img-fluid" /></div>
<div class="p-2">
<p><strong>Album title:</strong> {{albumDetails.title}}</p>
<p><strong>Owner’s name:</strong> {{albumUsers[albumDetails.id].name}}</p>
<p>Number of Photos: {{ 'PhotoDetails[$index]' | lengthOfObject }} </p>
</div>
</div>
<hr />
</li>
</ul>
<!-- template for displaying a contacts info -->
<script type="text/ng-template" id="calbumList.html">
<div>
<p>Go back to home page</p>
<ul>
<li ng-repeat="PhotoDetails in PhotoDetails">
<img src="{{PhotoDetails.thumbnailUrl}}" />
<div class="modal fade photoBig{{PhotoDetails.id}}" id="modalContainer" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel{{PhotoDetails.id}}" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<img src="{{PhotoDetails.url}}" />
</div>
</div>
</div>
</li>
</ul>
And here's the pen:
https://codepen.io/Menachem36/pen/eedbgb
Any idea?
Thanks

AngularJS element ID loaded with ng-include not found in index.html?

So the flow is I visit / then the script load main.html which include header.html then inject to ng-view in index.html
Here is the detail
My index.html
<!DOCTYPE HTML>
<html>
<head>
<title>Koupon - Index</title>
<!-- meta info -->
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="keywords" content="Koupon HTML5 Template" />
<meta name="description" content="Koupon - Premiun HTML5 Template for Coupons Website">
<meta name="author" content="Dark Cyber" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Google fonts -->
<!-- <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,600' rel='stylesheet' type='text/css'> -->
<!-- <link href='http://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'> -->
<!-- Bootstrap styles -->
<link rel="stylesheet" href="css/boostrap.css">
<link rel="stylesheet" href="css/boostrap_responsive.css">
<!-- Font Awesome styles (icons) -->
<link rel="stylesheet" href="css/font_awesome.css">
<!-- Main Template styles -->
<link rel="stylesheet" href="css/styles.css">
<!-- IE 8 Fallback -->
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="css/ie.css" />
<![endif]-->
<!-- Your custom styles (blank file) -->
<link rel="stylesheet" href="css/mystyles.css">
<!-- Backend Style -->
<!-- End Backend Style -->
</head>
<body ng-app="rentalkika">
<!-- //// START PAGE CONTENT -->
<div ng-view>
</div>
<!-- END PAGE CONTENT /// -->
<!-- Scripts queries -->
<script src="js/jquery.js"></script>
<script src="js/boostrap.min.js"></script>
<script src="js/nivo_slider.min.js"></script>
<script src="js/countdown.min.js"></script>
<script src="js/magnific.min.js"></script>
<script src="js/tweet.min.js"></script>
<!--
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script src="js/gmap3.min.js"></script>
-->
<script src="js/wilto_slider.min.js"></script>
<script src="js/mediaelement.min.js"></script>
<script src="js/fitvids.min.js"></script>
<script src="js/mail.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular-route.js"></script>
<script src="js/ng-file-upload-shim.js"></script>
<script src="js/ng-file-upload.js"></script>
<script src="js/app.js"></script>
<script src="js/flexnav.min.js"></script>
<!-- Custom scripts -->
<script src="js/custom.js"></script>
<script type="text/javascript" >
if($('#something').length){
alert('something found');
//I want to init plugin with #something here
}else{
alert('something not found');
}
</script>
<!-- Backend JS -->
<!-- End Backend JS -->
</body>
</html>
app.js
$routeProvider
.when('/', {
templateUrl : 'pages/main.html',
title: "Home"
})
main.html
<div ng-include="'header.html'"></div>
<!-- TOP AREA -->
<div class="top-area">
<!-- START BOOTSTRAP CAROUSEL -->
<div id="my-carousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="img/1200x480.png" alt="Image Alternative text" title="Old No7" />
<div class="carousel-caption countdown-caption">
<h3>Jack Daniels Huge Pack</h3>
<!-- COUNTDOWN -->
<div data-countdown="Aug 25, 2013 5:30:00" class="countdown"></div>Save 70%
</div>
</div>
<div class="item">
<img src="img/1200x480.png" alt="Image Alternative text" title="iPhone 5 iPad mini iPad 3" />
<div class="carousel-caption countdown-caption">
<h3>Apple Big Deal</h3>
<!-- COUNTDOWN -->
<div data-countdown="Aug 30, 2013 10:45:00" class="countdown"></div>Save 50%
</div>
</div>
<div class="item">
<img src="img/1200x480.png" alt="Image Alternative text" title="the best mode of transport here in maldives" />
<div class="carousel-caption countdown-caption">
<h3>Finshing in Maldives</h3>
<!-- COUNTDOWN -->
<div data-countdown="Sep 2, 2013 22:00:00" class="countdown"></div>Save 30%
</div>
</div>
</div>
<a class="carousel-control left" href="#my-carousel" data-slide="prev"></a>
<a class="carousel-control right" href="#my-carousel" data-slide="next"></a>
</div>
<!-- END BOOTSTRAP CAROUSEL -->
</div>
<!-- END TOP AREA -->
<div ng-include="'footer.html'"></div>
header.html
<!-- //////////////////////////////////
//////////////MAIN HEADER/////////////
////////////////////////////////////-->
<div id="something">
</div>
<header class="main">
<div class="container">
<div class="row">
<div class="span2">
<a href="index.html">
<img src="img/logo-small.png" alt="logo" title="logo" class="logo">
</a>
</div>
<div class="span8">
<!-- MAIN NAVIGATION -->
<div class="flexnav-menu-button" id="flexnav-menu-button">Menu</div>
<nav>
<ul class="nav nav-pills flexnav" id="flexnav" data-breakpoint="800">
<li class="active">Home
</li>
<li>Layanan
<ul>
<li>Sewa Mobil
</li>
<li>Shuttle
</li>
</ul>
</li>
<li>Paket Wisata
<ul>
<li>xxx</li>
<li>bbb</li>
</ul>
</li>
<li>Blog
</li>
<li>FAQ
</li>
<li>Tertarik menjadi mitra kami?</li>
<li>Contact
</li>
</ul>
</nav>
<!-- END MAIN NAVIGATION -->
</div>
<div class="span2">
<!-- LOGIN REGISTER LINKS -->
<ul class="login-register" ng-controller="LoginController">
<li ng-hide="loggedIn"><a class="popup-text" href="#login-dialog" data-effect="mfp-move-from-top"><i class="icon-signin"></i>Sign in</a>
</li>
<li ng-show="loggedIn"><i class="icon-signout"></i>Sign out
</li>
<li><i class="icon-edit"></i>Sign up
</li>
<!-- LOGIN REGISTER LINKS CONTENT -->
<div id="login-dialog" class="mfp-with-anim mfp-hide mfp-dialog clearfix">
<i class="icon-signin dialog-icon"></i>
<h3>Member Login</h3>
<h5>Welcome back, friend. Login to get started</h5>
<div class="row-fluid">
<form class="dialog-form" ng-submit="handleLogin()" >
<label>Username</label>
<input type="text" placeholder="yourUsername" ng-model="login.username" class="span12">
<label>Password</label>
<input type="password" placeholder="My secret password" ng-model="login.password" class="span12">
<label class="checkbox">
<input type="checkbox">Remember me
</label>
<div class="control-group error" ng-show="error">
<span class="error help-block">
{{ error }}
</span>
</div>
<input type="submit" value="Sign in" class="btn btn-primary">
<button ng-click="FBLogin()" class="btn btn-primary">Login with Facebook</button>
</form>
</div>
<!--
<ul class="dialog-alt-links">
<li><a class="popup-text" href="#register-dialog" data-effect="mfp-zoom-out">Not member yet</a>
</li>
<li><a class="popup-text" href="#password-recover-dialog" data-effect="mfp-zoom-out">Forgot password</a>
</li>
</ul>
-->
</div>
</ul>
</div>
</div>
</div>
</header>
<div id="password-recover-dialog" class="mfp-with-anim mfp-hide mfp-dialog clearfix">
<i class="icon-retweet dialog-icon"></i>
<h3>Password Recovery</h3>
<h5>Fortgot your password? Don't worry we can deal with it</h5>
<div class="row-fluid">
<form class="dialog-form">
<label>E-mail</label>
<input type="text" placeholder="email#domain.com" class="span12">
<input type="submit" value="Request new password" class="btn btn-primary">
</form>
</div>
</div>
<!-- END LOGIN REGISTER LINKS CONTENT -->
<!-- //////////////////////////////////
//////////////END MAIN HEADER//////////
////////////////////////////////////-->
The above script will alert something not found but if I put <div id="something"></div> directly to index.html the script will alert something found
What I need is <div id="something"></div> in header.html then I init plugin with #something in index.html
Is something wrong with my structure or code?
<div id="something" ng-controller="SomethingController">
</div>
then in your SomethingController
$("#something").initPlugin();

How do I prevent InAppBrowser from auto running with AngularJS $route?

My app is running Cordova with AngularJS routing. I need the InAppBrowser plugin to view pdfs. However, since ngroute calls an html on a route change InAppBrowser is called.
I only need it to run on button click not everytime.
-- edit --
When I have the Cordova InAppBrowser plugin installed I get a white screen and a message regarding a white list issue regarding my inital route "index.html":
$routeProvider
.when('/', { //load home at start
controller: 'HomeController as homeSlides',
templateUrl: 'content/home.html',
resolve: {
// I will cause a 1 second delay
delay: function ($q, $timeout) {
var delay = $q.defer();
$timeout(delay.resolve, 1000);
var dl = document.getElementById('door-left');
var dr = document.getElementById('door-right');
dl.classList.remove('open');
dr.classList.remove('open');
return delay.promise;
}
}
})
If I uninstall the plugin the issue is resolved.
-- edit --
This is the error I'm getting:
HTML1300: Navigation occurred.
[object Object]
APPHOST9623: The app couldn’t resolve ms-appx://25052ninjadrew.nanosales/www/[object Object] because of this error: RESOURCE_NOT_FOUND.
APPHOST9613: The app couldn’t navigate to ms-appx://25052ninjadrew.nanosales/www/[object Object] because of this error: 80004005.
new transaction is waiting for open operation
HTML1527: DOCTYPE expected. Consider adding a valid HTML5 doctype: "<!DOCTYPE html>".
[object Object] (1,1)
DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
index.html
-- edit --
For client reasons I can't show too much of my html but...
<!DOCTYPE html>
<html ng-app="nanoApp" class="test">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="css/main.css">
<script src="js/winstore-jscompat.js"></script>
<script src="js/min/iscroll-min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/ngroute.min.js"></script>
<script src="js/angular-sanitize.js"></script>
<script src="js/ng-cordova.min.js"></script>
<script src="cordova.js"></script>
<script src="js/database.js"></script>
<script src="js/angular-script.js"></script>
</head>
<body class="{{bodyclass}}">
<div id="door-left" style="background-image:url('img/trans-left.png');" class="loading door-left" ></div>
<div id="door-right"style="background-image:url('img/trans-right.png');" class="loading door-right" ></div>
<div id="nav">
<ul>
<li><span id="menu-cls" class="ion-close-round"></span></li>
<li><div class="ion-grid"></div>Home</li>
<li><div class="ion-grid"></div>Products</li>
<li><div class="ion-grid"></div>Installations</li>
<li><div class="ion-grid"></div>Videos</li>
<li><div class="ion-grid"></div>Favorites</li>
<li><div class="ion-grid"></div>Marketing Materials</li>
</ul>
</div>
<div id="head">
<div id="left-head">
<div id="menu-btn"></div>
<img src="img/header-left-x2.png" />
<div class="filler"></div>
</div>
<div id="middle-head">
<a style="display:block;" href="#/"><div id="logo"></div></a>
</div>
<div id="right-head">
<img src="img/header-right-x2.png" />
</div>
<div class="swipe-indicator"><span class="ion-chevron-left three"></span><span class="ion-chevron-left two"></span><span class="ion-chevron-left one"></span> Swipe <span class="ion-chevron-right one"></span><span class="ion-chevron-right two"></span><span class="ion-chevron-right three"></span></div>
</div>
<div id="content" class="scroller" ng-view>
</div>
<div id="footer">
<ul id="footer-btns">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<div class="filler"></div>
<img src="img/bottom-bar-x2.png" class="bottom-bar" />
</div>
<!-- gallery popup -->
<div id="gallery-container" ng-show="openGallery">
<div class="ion-close-round close-gallery" ng-click="closeGallery()"></div>
<div id="left-arrow" class="arrow" ng-click="prevSlide()" ng-show="galleryCount > 1"></div>
<div id="slide-container">
<div id="slides">
<div class="slide" ng-repeat="slide in gallery" ng-switch on="galleryType" video-setup>
<!-- image template-->
<img ng-src="{{slide.file}}" ng-switch-when="image" />
<!-- video template-->
<video class="video" style="width:845px;height:635px;" controls autoplay ng-switch-when="video">
<source ng-src="{{slide.file}}" type='video/mp4' />
</video>
</div>
</div>
</div>
<div id="slide-marker-container" ng-show="galleryCount > 1">
<ul id="slide-markers">
<li ng-repeat="marker in galleryMarkers(galleryCount) track by $index" marker-setup>
<div ng-click="scrollToSlide({{$index}})"></div>
</li>
</ul>
</div>
<div id="right-arrow" class="arrow" ng-click="nextSlide()" ng-show="galleryCount > 1"></div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/stellar.min.js"></script>
<script src="js/main.js"></script>
</body>
</html>
home.html:
<div id="home" set-iscroll home-setup class="container paralax">
<a href="#/productslist/0" class="section">
<div style="background-image:url('img/home/slim-home-bkg.jpg');" class="bkg"></div>
<div style="background-image:url('img/home/slim-title.png');" class="element layer1" data-stellar-ratio="1.3"></div>
<div id="slim-holt-top" class="indicator"><div style="background-image:url('img/home/slim-holt-top.png');" class="element title" data-stellar-ratio="1.3"></div></div>
<div id="slim-lv-top" class="indicator"><div style="background-image:url('img/home/slim-lv-top.png');" class="element layer2" data-stellar-ratio="1.7" data-stellar-ratio="2"></div></div>
<div id="slim-mel-top" class="indicator"><div style="background-image:url('img/home/slim-mel-top.png');" class="element layer3" data-stellar-ratio="1.3"></div></div>
<div id="slim-avyve-top" class="indicator"><div style="background-image:url('img/home/slim-avyve-top.png');" class="element layer4" data-stellar-ratio="1.2"></div></div>
</a>
<a href="#/productslist/1" class="section">
<div style="background-image:url('img/home/curve-home-bkg.jpg');" class="bkg"></div>
<div style="background-image:url('img/home/curve-title.png');" class="element title" data-stellar-ratio="1.3"></div>
<div id="curve-aig-top" class="indicator"><div style="background-image:url('img/home/curve-aig-top.png');" class="element layer1" data-stellar-ratio="1.7"></div></div>
<div id="curve-illy-top" class="indicator"><div style="background-image:url('img/home/curve-illy-top.png');" class="element layer2" data-stellar-ratio="1.5" data-stellar-ratio="2"></div></div>
<div id="curve-minn-top" class="indicator"><div style="background-image:url('img/home/curve-minn-top.png');" class="element layer3" data-stellar-ratio="1.2"></div></div>
</a>
<a href="#/productslist/2" class="section">
<div style="background-image:url('img/home/clear-home-bkg.jpg');" class="bkg"></div>
<div style="background-image:url('img/home/clear-title.png');" class="element title" data-stellar-ratio="1.3"></div>
<div id="clear-top" class="indicator"><div style="background-image:url('img/home/clear-top.png');" class="element layer1" data-stellar-ratio="1.5"></div></div>
</a>
<a href="#/productslist/3" class="section">
<div style="background-image:url('img/home/wrap-home-bkg.jpg');" class="bkg"></div>
<div style="background-image:url('img/home/wrap-title.png');" class="element title" data-stellar-ratio="1.3"></div>
<div id="wrap-eaton-top" class="indicator"><div style="background-image:url('img/home/wrap-eaton-top.png');" class="element layer2" data-stellar-ratio="1.2"></div></div>
<div id="wrap-gte-top" class="indicator"><div style="background-image:url('img/home/wrap-gte-top.png');" class="element layer3" data-stellar-ratio="1.5"></div></div>
</a>
<a href="#/productslist/4" class="section">
<div style="background-image:url('img/home/slimengage-home-bkg.jpg');" class="bkg"></div>
<div style="background-image:url('img/home/slimengage-title.png');" class="element title" data-stellar-ratio="1.3"></div>
<div id="slimengage-screen" class="indicator"><div style="background-image:url('img/home/slimengage-screen.png');" class="element layer1" data-stellar-ratio="1.1"></div></div>
<div id="slimengage-blueppl" class="indicator"><div style="background-image:url('img/home/slimengage-blueppl.png');" class="element layer2" data-stellar-ratio="1"></div></div>
<div id="slimengage-colorppl" class="indicator"><div style="background-image:url('img/home/slimengage-colorppl.png');" class="element layer3" data-stellar-ratio="1.5"></div></div>
</a>
</div>

Resources