Hide sidebar for particular page in Mobile Angular Ui.(Angular Js) - javascript

I am using mobile angular ui. I want to hide side for particular page.
http://mobileangularui.com/
This side bar by default put in every page. But i don't want this side bar in home page. Mobile angular ui have one index.html file. One sidebar.html import in index file. And every page import in index file. But when come home.html file will come then sidebar should be hide.
Index.html
<html>
<head>
<meta charset="utf-8" />
<title>y</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
<link rel="stylesheet" href="css/app.min.css" />
<link rel="stylesheet" href="css/responsive.min.css" />
<!-- inject:js -->
<script src="js/app.min.js"></script>
</head>
<style>
.color-winni-text
{
color:#c62222;
}
</style>
<body ng-app="Y" ng-controller="MainController">
<!-- Sidebars -->
<div ng-include="'sidebar.html'"
ui-track-as-search-param='true'
class="sidebar sidebar-left">
</div>
<div class="app">
<!-- Navbars -->
<div class="navbar navbar-app navbar-absolute-top">
<div class="navbar-brand navbar-brand-center " ui-yield-to="title">
<a class="color-winni-text" href="#/"> <strong>Winni Celebration</strong></a>
</div>
<div class="btn-group pull-left">
<div ui-toggle="uiSidebarLeft" class="btn sidebar-toggle">
<i class="fa fa-bars color-winni-text fa-2x"></i>
</div>
</div>
<div class="btn-group pull-right" ui-yield-to="navbarAction">
<div ui-toggle="uiSidebarRight" class="btn">
<i class="fa fa-sign-in color-winni-text"></i>
</div>
</div>
</div>
<div class="navbar navbar-app navbar-absolute-bottom">
<div class="btn-group justified">
<a style="color:#c62222" href="#/" class="btn btn-navbar"><i class="fa fa-home fa-navbar"></i> Home</a>
<a style="color:#c62222" href="#/my-winni" class="btn btn-navbar"><i class="fa fa-github fa-navbar"></i> My Winni</a>
<a style="color:#c62222" href="https://github.com/mcasimir/mobile-angular-ui/issues" class="btn btn-navbar"><i class="fa fa-exclamation-circle fa-navbar"></i> Issues</a>
</div>
</div>
<!-- App Body -->
<div class="app-body background-color-body" style="background-color:white" ui-prevent-touchmove-defaults>
<div class="app-content scrollable-content">
<ng-view></ng-view>
</div>
</div>
</div><!-- ~ .app -->
<div ui-yield-to="modals"></div>
</body>
</html>
Screen Shot of index file
App.js File.
angular.module('Y', [
'ngRoute',
'mobile-angular-ui',
'Y.controllers.Main'
])
.config(function($routeProvider) {
$routeProvider.when('/', {templateUrl:'home.html', reloadOnSearch: null})
.when('/cityPage', {templateUrl:'cityPage.html', reloadOnSearch: false})
.when('/category-prduct', {templateUrl:'category-prduct.html', reloadOnSearch: false})
.when('/product-description', {templateUrl:'product-description.html', reloadOnSearch: false})
.when('/my-winni', {templateUrl:'my-winni.html', reloadOnSearch: false})
.when('/gift-box', {templateUrl:'gift-box.html', reloadOnSearch: false});
});
I want to hide sidebar only on home.html page.

Try wrapping your <div ng-include="'sidebar.html'"> element in an ngIf directive that examines the location path.
You can inject the $location service into your MainController and expose the value of $location.path() to the template.
Example: $scope.currentPath = $location.path()
Then use:
<div ng-if="currentPath !== ''">
<div ng-include="'sidebar.html'">`
Also, use the controllerAs syntax instead of $scope.

Related

Using $state.go to change view issue

According the next code, i'm creating a login process, that process through a PHP file is working fine, but after success the view doesn't change, here:
(function (){
var app = angular.module('starter', ['ionic']);
var app2 = angular.module('nuevo', []);
app.controller('controller', function($scope, $http, $state) {
$scope.registrar = function(){
$http.post("http://127.0.0.1:8080/php/Conexion.php",{
correo:$scope.mail, pass:$scope.word,
}).success(function(data){
alert("SESIÓN INICIADA")
$state.go('main');
});
}
});
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('main', {
url: '/main',
templateUrl: 'templates/main.html',
controller: 'controller',
})
$urlRouterProvider.otherwise('/index.html');
});
My HTML file, here
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link rel="manifest" href="manifest.json">
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="cordova.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-app="starter">
<ion-pane>
<ion-header-bar class="bar-stable">
<div class=" col text-center">
<h3 >Taxi App</h3>
</div>
</ion-header-bar>
<div ng-controller="controller">
<img class="indexImg" src="img/saludoIndex.jpg">
<br><br>
<div class="item item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-at placeholder-icon"></i>
<input type="text" placeholder="Dirección de email" ng-model="mail">
</label>
</div>
<div class="item item-input-inset">
<label class="item-input-wrapper">
<i class="icon ion-locked placeholder-icon"></i>
<input type="text" placeholder="Contraseña" ng-model="word">
</label><br>
</div>
<div class="col text-center">
<br><h4><a>¿Olvidaste tu contraseña?</a></h4><br><br><br><br><br>
<a class="button button-stable button-large" href="templates/Register.html">
<b>Crear una cuenta gratuita</b></a>
</div>
<ion-footer-bar class="bar-positive tabs">
<a class="tab-item">
<h4 style="color:white;" ng-click="registrar()">INICIAR SESIÓN</h4>
</a>
</ion-footer-bar>
</div>
</ion-pane>
</body>
</html>
But the network log shows me the info inside the page (simple test data), main.html just have simple data for testing if change is working but doesn't load the page on app's screen.
I hope you can help me with this issue, thank you very much.
Reading more about this issue i found that i had to add on the body of index.html and main.html this and it works perfect

Angular.js: 13424 Error: [ng:areq] Argument 'enfermerosController' is not a function, got undefined

i'm getting Angular.js: 13424 Error: [ng:areq] Argument 'enfermerosController' is not a function, got undefinederror I don't know what is happening. Found in some places that it's maybe i'm calling ng-app twice or my module but I don't. I'm using Angular 1.5.3 and it's my first time with this problem. I will be grateful with any help you can give.
Thanks
This is my router
'use strict'
var myApp = angular.module('myApp', ['ngRoute', 'ui.bootstrap'])
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider.when('/', {
templateUrl: '/views/admin/partials/hola.html',
controller: 'adminController'
})
$routeProvider.when('/admin/geriatras', {
templateUrl: '/views/admin/partials/geriatras.html',
controller: 'geriatrasController'
})
$routeProvider.when('/admin/medicos', {
templateUrl: '/views/admin/partials/medicos.html',
controller: 'medicosController'
})
$routeProvider.when('/admin/enfermeros', {
templateUrl: '/views/admin/partials/enfermeros.html',
controller: 'enfermerosController'
})
$routeProvider.when('/admin/pacientes', {
templateUrl: '/views/admin/partials/pacientes.html',
controller: 'pacientesController'
})
$routeProvider.otherwise({
redirectTo: '/'
})
$locationProvider.html5Mode({
enabled: true,
requireBase: false
})
}])
and after this is one of my controllers pacientesController (with all I have the same problem)
'use strict'
myApp.controller('pacientesController',['$scope', ($scope) => {
$scope.hello = "hello"
}])
This is enfermerosController (as you see, there's no code yet in my controllers)
'use strict'
myApp.controller('enfermerosController', ['$scope', function($scope) {
}])
and my html is this one
<!DOCTYPE html>
<html lang="es" ng-app="myApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Hospital</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="/libs/bootstrap/dist/css/bootstrap.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="/public/assets/dist/css/Matadero.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<header class="main-header">
<!-- Logo -->
<a href="index2.html" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini"><b>:D</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg"><b>Hospital</span>
</a>
<!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only">Navegación</span>
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- Messages: style can be found in dropdown.less-->
<!-- Notifications: style can be found in dropdown.less -->
<!-- Tasks: style can be found in dropdown.less -->
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span class="hidden-xs">!!Nombre Usuario Loggeado¡¡</span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<!-- Menu Body -->
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
Perfil
</div>
<div class="pull-right">
Cerrar sesión
</div>
</li>
</ul>
</li>
<!-- Control Sidebar Toggle Button -->
</ul>
</div>
</nav>
</header>
<!-- Left side column. contains the logo and sidebar -->
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- search form -->
<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
</button>
</span>
</div>
</form>
<!-- /.search form -->
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul class="sidebar-menu" ng-controller="navController">
<li class="header">Menú</li>
<li class="active treeview">
<a href="#">
<i class="fa fa-dashboard"></i> <span>Personal Médico</span> <i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu">
<li ng-class="{active: isActive('/admin/geriatras')}"><i class="fa fa-circle-o"></i>Geriatras</li>
<li ng-class="{active: isActive('/admin/medicos')}"><i class="fa fa-circle-o"></i>Médicos</li>
<li ng-class="{active: isActive('/admin/enfermeros')}"><i class="fa fa-circle-o"></i>Enfermeros</li>
</ul>
</li>
<li ng-class="{active: isActive('/admin/pacientes')}"><i class="fa fa-book"></i> <span>Pacientes</span></li>
</ul>
</section>
<!-- /.sidebar -->
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Dashboard
<small>Panel de Control</small>
</h1>
</section>
<!-- Main content -->
<section class="content">
<div ng-view="">
</div>
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Equipo Fiucsa</b>
</div>
<strong>Tecnológico de Monterrey © 2016 Repositorio.</strong>
</footer>
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
<!--Angular -->
<script type="text/javascript" src="/libs/angular/angular.js"></script>
<script type="text/javascript" src="/libs/angular-route/angular-route.js"></script>
<script type="text/javascript" src="/public/js/app.js"></script>
<script src="/libs/angular-aria/angular-aria.js"></script>
<script src="/libs/angular-animate/angular-animate.js"></script>
<script src="/libs/angular-material/angular-material.js"></script>
<script src="/libs/angular-messages/angular-messages.js"></script>
<script type="text/javascript" src="/libs/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="http://ngmaterial.assets.s3.amazonaws.com/svg-assets-cache.js"></script>
<script type="text/javascript" src="/public/js/controllers/cuestionarioController.js"></script>
<script type="text/javascript" src="/public/js/controllers/geriatrasController.js"></script>
<script type="text/javascript" src="/public/js/controllers/medicosController.js"></script>
<script type="text/javascript" src="/public/js/controllers/enfermerosController.js"></script>
<script type="text/javascript" src="/public/js/controllers/navController.js"></script>
<script type="text/javascript" src="/public/js/controllers/adminController.js"></script>
<!-- jQuery 2.1.4 -->
<script src="/libs/jquery/dist/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<!-- Bootstrap 3.3.5 -->
<script src="/libs/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="/public/assets/dist/js/app.min.js"></script>
</body>
</html>
I just found my error and it was the arrow functions when I define my controllers. I think we can only use arrow functions inside controllers not when you define it
theres a little explanation here:
Are ES6 arrow functions incompatible with Angular?

Redirect with angularJs - but only inside div/main element

I have an html page with a header, main and footer (I use materialize and angularJS). I always want the header and footer to remain the same, but when I press links in the sidenav I want the main element to be another html page. Let's say I press the info link in the sidenav, I want the header and footer to remain, but I move from the main part of the html to another page. This is what I have so far:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<title>MyPage</title>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
</head>
<body ng-app="myPage" ng-controller="mainCtrl">
<header>
<ul id="sidenav" class="side-nav fixed light-blue lighten-1">
<li><a id="page" class="white-text text-accent-1" href="#">Home</a> </li>
<br/><br/>
<li><a id="page1" class="white-text text-accent-1" href="#"><b>Info</b></a></li>
<li><a id="page2" class="white-text text-accent-1" href="#"><b>Another page</b></a></li>
<li><a id="page3" class="white-text text-accent-1" href="#"><b>Even one more page</b></a></li>
</ul>
</header>
<main>
<div id="main">
<p> Some text for main page here </p>
</div>
</main>
<footer class="page-footer orange">
<div class="container">
<div class="row">
<div class="col l6 s12">
<h5 class="white-text">About</h5>
<p class="grey-text text-lighten-4">
About my company.
</p>
</div>
</div>
</div>
</footer>
<!-- Scripts-->
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/materialize.js"></script>
<script src="controllers/mainCtrl.js"></script>
</body>
</html>
This might be really easy, but I haven't found out how to be able to switch back and forth, and also keep the header and footer. I tried to just link the new html page into , but then I have to copy over the header and footer, which is not ideal. I don't want to have possibly 10-15 html pages I have to edit if I want to change the sidenav for example.
You have to set up a router and put a ng-view directive on some of your html elements:
...
</header>
<div ng-view>
<main>
...
</main>
</div>
<footer class="page-footer orange">
...
simple routing example:
app.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/home', {
templateUrl: 'home.html',
controller: 'homeCtrl',
);
}]);
If you than use your sidebar link
<a id="page" class="white-text text-accent-1" href="#/home">Home</a>
The routeProvider will load your home.html and homeCtrl between the defined element with the ng-view directive

Set image in mobile angular ui website

I am implement mobile website. I am using mobileangularui framework for mobile website. I want to set image in home.html, But i could not set image from image folder.If i put URL of image which is exist in server then it is works. I will show screen shot of code snippet.
Existing output:
home.html
<style>
.bgImage
{
background-image: url('http://www.electricshop.com/editordocs/image/OurTopGiftIdeas231215_978x400.png');
height:330px;
background-position: center center;
}
</style>
<div class="jumbtron scrollable-content">
<div class="bgImage">
</div>
<img src="../images/clocks.jpg">
<img src="http://1.bp.blogspot.com/-NFIfiFmg8SA/Ti0xrNqB4OI/AAAAAAAADno/fB_2wYQBiv4/s1600/silence-between-two-people.jpg">
</div>
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>y</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimal-ui" />
<meta name="apple-mobile-web-app-status-bar-style" content="yes" />
<link rel="stylesheet" href="css/app.min.css" />
<link rel="stylesheet" href="css/responsive.min.css" />
<script src="http://localhost:8001/target/target-script-min.js"></script>
<script src="cordova.js"></script>
<script src="js/app.min.js"></script>
</head>
<style>
.color-winni-text
{
color:#c62222;
}
</style>
<body ng-app="Y" ng-controller="MainController">
<!-- Sidebars -->
<div ng-include="'sidebar.html'"
ui-track-as-search-param='true'
class="sidebar sidebar-left"></div>
<div class="app">
<!-- Navbars -->
<div class="navbar navbar-app navbar-absolute-top">
<div class="navbar-brand navbar-brand-center color-winni-text" ui-yield-to="title">
<strong>Winni Celebration</strong>
</div>
<div class="btn-group pull-left">
<div ui-toggle="uiSidebarLeft" class="btn sidebar-toggle">
<i class="fa fa-bars color-winni-text fa-2x"></i>
</div>
</div>
<div class="btn-group pull-right" ui-yield-to="navbarAction">
<div ui-toggle="uiSidebarRight" class="btn">
<i class="fa fa-comment color-winni-text"></i>
</div>
</div>
</div>
<div class="navbar navbar-app navbar-absolute-bottom">
<div class="btn-group justified">
<i class="fa fa-home fa-navbar"></i> Docs
<i class="fa fa-github fa-navbar"></i> Sources
<i class="fa fa-exclamation-circle fa-navbar"></i> Issues
</div>
</div>
<!-- App Body -->
<div class="app-body background-color-body">
<div class="app-content">
<ng-view></ng-view>
</div>
</div>
</div><!-- ~ .app -->
<div ui-yield-to="modals"></div>
</body>
</html>
When i give
<img src="../images.clocks.jpg">
then it is not works, But i give image url which is exist in server then it is works.
Directory Screen Shot:
Please give me some idea.

Twitter Bootstrap alert close does not work

I use Bootstrap 3.0.3 and JQuery 2.0.3
My html code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Encoding" content="gzip" />
<meta http-equiv="Accept-Encoding" content="gzip, deflate" />
<title>#L("CONTROL_PANEL") | #ViewBag.Title</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta content="L" />
#Styles.Render("~/content/admin/css")
<link type="text/css" href="/Content/jquery.mCustomScrollbar.css" rel="stylesheet" media="all" />
#RenderSection("css", false)
</head>
<body>
<section id="container">
<header class="navbar navbar-fixed-top">
<div class="title">
<span>#L("CONTROL_PANEL")</span>
</div>
</header>
<aside class="sidebar">
<menu class="fisrt">
<li class="active">
<a href="#">
<i class="fa fa-2x fa-tachometer"></i>
#L("PANEL")
</a>
<span class="separator"></span>
</li>
</menu>
<menu class="second">
#RenderSection("second_menu", false)
</menu>
</aside>
<menu class="breadcrumb">
<li><span>Панель</span></li>
<li><span>Новости</span></li>
</menu>
<section class="main-content">
<div class="panel panel-dark">
<div class="panel-heading">
<h3 class="panel-title">#ViewBag.PanelTitle</h3>
</div>
<div class="panel-body">
<div class="content">
#{
if (this.TempData["Success"] != null)
{
<div class="alert alert-success fade in">
<a href="#" class="close close-sm" data-dismiss="alert" aria-hidden="true">
<i class="fa fa-times"></i>
</a>
<h4>
<i class="fa fa-check-circle"></i> #L("SUCCESS")
</h4>
<p>#this.TempData["Success"]</p>
</div>
}
if (this.TempData["Error"] != null)
{
<div class="alert alert-danger fade in">
<button type="button" class="close close-sm" data-dismiss="alert">
<i class="fa fa-times"></i>
</button>
<strong>Oh snap!</strong> Change a few things up and try submitting again.
</div>
}
}
<div>
#RenderBody()
</div>
</div>
</div>
</div>
</section>
<footer>
Время генерации страницы #TempData["Time"]
</footer>
</section>
<!-- Scripts -->
#Scripts.Render("~/js")
<!-- the jScrollPane script -->
<script type="text/javascript" src="/scripts/jquery.mCustomScrollbar.concat.min.js"></script>
#RenderSection("js", false)
<script type="text/javascript">
(function ($) {
$(window).load(function () {
$(".content > div").mCustomScrollbar({
theme: "dark-thick",
advanced: {
autoScrollOnFocus: false,
updateOnContentResize: true
}
});
});
})(jQuery);
</script>
</body>
</html>
When I try close message, I get error
TypeError: elem.getAttribute is not a function.
elem.getAttribute( name ) : jquery-2.0.3.js (строка 1707)
Update
I don't know Why but if change Jquery from NuGet to google start work.
I don't know Why but if change Jquery from NuGet to google start work.
Google offers you the latest jQuery 1.x maybe. Before you used 2.0.3. Bootstrap only supports the 1.x release. (jQuery 2.x drops support for IE8 and Bootstrap still support this).
See also: http://getbootstrap.com/getting-started. The basic example template includes https://code.jquery.com/jquery.js which offers version 1.10.2.
https://github.com/twbs/bootstrap/blob/v3.0.3/bower.json shows you Bootstrap 3.0.3 requires >= 1.9.0

Categories

Resources