Onsen carousel & template with json - angularjs

I have an Onsen-UI template/index where I have a carousel and have each carousel-item calling a ons-template id (html). One of those templates is calling for ng-controller (which is calling for json api) and has usual javascript within it.
If I view the index.html in Chrome, the list shows but when I build it as phonegap app and run the apk on my android device, the list never appears. It just loads in a loop without 'loading' it.
Also, when I click on a list item it should take me to another html template to display the correct information and where (page.html), which Chrome doesn't do (could be just an issue in chrome).
I'm hoping if I get the list to display on my app, then the second part would fix itself or do I need to do some extra tweaking?
Here is my template code calling the controller:
<ons-template id="news.html">
<ons-page>
<div class="app-page opacity-bar">
<div class="app-page-content">
<div class="app-page news-page" ng-controller="newsController" data-ng-init="getAllRecords()">
<ons-list modifier="news">
<ons-list-item modifier="chevron" class="list-item-container" ng-repeat="item in items" ng-click="showPost($index)">
<ons-row>
<ons-col width="95px">
<img ng-show="{{ item.thumbnail_images }}" ng-src="{{ item.thumbnail_images.thumbnail.url }}" class="thumbnail">
</ons-col>
<ons-col>
<div class="name">
{{ item.title | limitTo: 15 }}...
</div>
<div class="location" ng-show="{{ item.categories }}">
<i class="ion-pricetags"></i> <span ng-repeat="cat in item.categories">{{cat.title}} </span>
</div>
<div class="desc">
{{ item.excerpt | htmlToPlaintext | limitTo: 60 }}...
</div>
</ons-col>
<ons-col width="40px"></ons-col>
</ons-row>
</ons-list-item>
</ons-list>
<ons-button id="moreButton" modifier="large" should-spin="{{isFetching}}" ng-click="nextPage()">more news</ons-button>
</div></div></div>
</ons-page>
</ons-template>

The carousel is very weak, bad implemented, i have same issue too, and the support is NULL

May be this link will help for you, Check with the code
<ons-page>
<ons-toolbar>
<div class="center">Carousel</div>
</ons-toolbar>
<ons-carousel ng-controller="CarouselController" swipeable auto-scroll fullscreen var="carousel">
<ons-carousel-item style="background-color: gray;">
<div class="item-label">GRAY</div>
</ons-carousel-item>
<ons-carousel-item style="background-color: #085078;">
<div class="item-label">BLUE</div>
</ons-carousel-item>
<ons-carousel-item style="background-color: #373B44;">
<div class="item-label">DARK</div>
</ons-carousel-item>
<ons-carousel-item style="background-color: #D38312;">
<div class="item-label">ORANGE</div>
</ons-carousel-item>
<ons-carousel-cover>
<div class="bullets">
<span
ng-repeat="idx in indices"
ng-class="{'active': idx === carousel.getActiveCarouselItemIndex()}">
•
</span>
</div>
</ons-carousel-cover>
</ons-carousel>
</ons-page>

Related

ion-option-buttons showing if i put ng-change on ion-toggle

Good day! Im fairly new to ionic and mobile dev. Im making a simple reminder app and Im implementing ion-toggle
Here what my code looks like,
<ion-item class="item-avatar" ng-repeat="med in meds.medications" >
<img ng-src={{med.medicine.image_url}} style="top: 25px;">
<div class="row">
<div class="col col-50 col-center">
<h2>{{ med.medicine.name }}</h2>
<p>{{ med.dose +' '+med.type }}</p>
<p style="font-weight: bold" >{{ med.time }}</p>
</div>
<div class="col" style="border: 0">
<ion-toggle ng-checked="!med.status" toggle-class="toggle-calm" style="border: 0;"> </ion-toggle>
</div>
</div>
<ion-option-button class="button-positive" ng-click="meds.showEditMed(med)">Edit</ion-option-button>
<ion-option-button class="button-assertive" ng-click="meds.showDeleteMed(med)">Delete</ion-option-button>
</ion-item>
I have a very weird problem, whenever I put ng-change on my ion-toggle, the option button shows up. Ive looked up the net for some solutions, none of which have this the same problem.
Here is an image of my problem
Thank you very much for your help
Use ng-model on ion-toggle, here is the sample code:
<ion-toggle ng-model="someVariable" ng-checked="!med.status" toggle-class="toggle-calm" style="border: 0;"> </ion-toggle>
ooops, my bad. I forgot to put ng-model on the ion-toggle.

How do I make one button as default in angular?

I have some group of buttons in angular material code, so I want to make the first button as default, where it shows the content of that button on right side.
I have written some code like below, it shows the result after I clicked the button.
<div layout="row" layout-align="space-between">
<div class="list" style="width:30%;height:50px">
<div layout="column" ng-repeat="lists in vm.result | filter:searchText">
<div layout="row" layout-align="space-around">
<md-button class="md-raised" ng-click="vm.showItems(lists._id)">{{lists.wName}}'s Wish List {{$index}}</md-button>
<a style="margin-top:14px; cursor:pointer">{{lists.wType}}</a>
</div>
</div>
</div>
<div class="listItems" style="width:68%;height:400px;">
<div flex-xs flex-gt-xs="30" layout="row" ng-show="vm.showOnClick">
<md-card ng-repeat="product in vm.result" flex="30" style="max-width: 50%;">
<md-card-title>
<md-card-title-text>
<span class="md-subhead">{{product.Product_Name}}</span>
</md-card-title-text>
</md-card-title>
<md-card-title-media style="margin-left: -80px;">
<img ng-src="{{ product.Image }}" class="md-card-image" alt="Image here">
</md-card-title-media>
<md-card-title-text>
<span><span class="md-subhead" style="font-weight: bold; padding:2px;">Price: </span> {{ product.Price }}</span><br/>
<span><span class="md-subhead" style="font-weight: bold; padding:2px;">Brand:</span> {{ product.Brand }}</span><br/>
<span><span class="md-subhead" style="font-weight: bold; padding:2px;">Category: </span> {{ product.Category }}</span><br/>
</md-card-title-text>
</md-card>
</div>
</div>
What you are trying to achieve is to have the first item selected as default when your page is displayed. To do this, your controller should run the showItems method for the first item in the list once they have loaded.
I don't know what your controller or service looks like, but it would be something like (in your controller)
itemsService.loadItems().then(function(items) {
showItems(items[0]);
});

pass value from one ons-template to another using angular js [Onsen UI]

I want some values from one ons-template to another, i have tried sending values from ons-template to controller and getting back to another ons-template from a controller, but is there any way i can get the values directly from one ons-template to another without calling the controller? Below is my code.
sendmoney.html
<ons-template id="sendmoney.html">
<ons-page modifier="shop-details" class='page_bg'>
<ons-toolbar style="background-color: #16A500;">
<div class="left">
<ons-toolbar-button ng-click="menu.openMenu();">
<ons-icon icon="ion-navicon" size="28px" fixed-width="false"></ons-icon>
</ons-toolbar-button>
</div>
<div class="center">Send Money</div>
<div class="right">
<ons-toolbar-button onclick="doContactPicker()">
<ons-icon icon="ion-plus" size="28px" fixed-width="false"></ons-icon>
</ons-toolbar-button>
</div>
</ons-toolbar>
<div ng-controller="getUserContacts">
<ons-list-header>Select Contact</ons-list-header>
<ons-list style="margin: -1px 0">
<div ng-show="loading" class="loading"><img src="img/loading.gif" height="50px" width="50px"></div>
<ons-list-item modifier="chevron" class="list-item" ng-repeat="x in contacts track by $index" style="margin-left: 10px;" ng-click="page.pushPage('sendmoney2.html', {animation: 'slide'});">
<ons-row>
<ons-col width="52px" style="padding: 10px 0 0 0;">
<img src="img/red.png" height="42px" width="42px"/>
</ons-col>
<ons-col>
<header>
<span class="item-title">{{x.name}}</span>
</header>
<p class="swipe-item-desc">{{x.phone}}</p>
</ons-col>
</ons-row>
</ons-list-item>
</ons-list>
</div>
</ons-page>
</ons-template>
I want {{x.name}} and {{x.phone}} in sendmoney2.html template
sendmoney2.html
<ons-template id="sendmoney2.html">
<ons-page modifier="shop-details" class='page_bg'>
<ons-toolbar style="background-color: #16A500;">
<div class="left">
<ons-toolbar-button ng-click="menu.openMenu();">
<ons-icon icon="ion-navicon" size="28px" fixed-width="false"></ons-icon>
</ons-toolbar-button>
</div>
<div class="center">Send Money</div>
</ons-toolbar>
</ons-page>
</ons-template
I don't know Angular very well, but in plain JS, you simply set a global variable to get around this. I think of the app design as just one large web page. That often helps me solve my problems. So basically just define these in the top of your script:
var vName = '';
var vPhone = '';
Then set them in the events, this should work.

Angular ng-click onsen

So im new to coding and i cant seem to figure out some issue that i have.
<ons-row ng-click="myNavigator.pushPage('{{building.file}}.html')">
So i started and the {{ building.file }} isn't going to the url. can someone help me or explain why it isnt workking? here is my complete code
<div ng-init="buildings = [
{name:'name1',file:'file1', location:'location1', image:'images/img1.jpg', number:'(123) 400-0000'},
{name:'name2',file:'file2', location:'location2', image:'images/img2.jpg', number:'(123) 400-0000'},
{name:'name3',file:'file3', location:'location3', image:'images/img3.jpg', number:'(123) 400-0000'},
]">
<!--There Are {{buildings.length}} restaurants-->
<input type="search" ng-model="q" class="search-input" placeholder="Search..." />
<br />
<ons-list >
<ons-list-item modifier="chevron" class="list-item-container" ng-repeat="building in buildings | filter:q as results">
<ons-row ng-click="myNavigator.pushPage('/' + {{building.file}} + '.html')">
<ons-col width="95px">
<img src="{{building.image}}" class="thumbnail">
</ons-col>
<ons-col>
<div class="name">
{{building.name}}
</div>
<div class="location">
<i class="fa fa-map-marker"></i> {{building.location}}
</div>
<div class="desc">
{{building.number}}
</div>
</ons-col>
<ons-col width="40px"></ons-col>
</ons-row>
</ons-list-item>
</ons-list>
<ul class="example-animate-container">
<li class="animate-repeat" ng-if="results.length == 0">
<strong>No results found...</strong>
</li>
<li class="animate-repeat" ng-if="results.length == 555">
<strong>No results found...</strong>
</li>
</ul>
I don't have your exact code but i think u should not use expression within function call. I created sample demonstration for your app Demo. Please check on console by clicking on name. it logs correct url. Hope this helps!
<div ng-click="pushPage('/' + building.file + '.html')">
{{building.name}}
</div>
I don't see the ons-navigator in your code. The easiest way in angular is to use a var for ons-navigator and then you can use myNavigator.pushPage('name')
<ons-navigator var="myNavigator">
<ons-page>
<ons-row ng-click="myNavigator.pushPage('file.html')" > My Row </ons-row>
</ons-page>
</ons-navigator>
<ons-template id="file.html">
<ons-page>
My Content
</ons-page>
</ons-template>

Doesn't show div in onsen ui and angularjs

in my app i try to show my search div into my toolbar. Now my searchbar is outside from my toolbar and works fine (show and hide when i click on my search button). When i try to put my searchbar into my toolbar my search button doesnt work (doesnt show).
My html code:
<ons-page ng-controller="alojamientosController" data-ng-init="getAllRecords()">
<ons-toolbar>
<div class="left">
<ons-toolbar-button ng-click="menu.toggle()"><ons-icon icon="ion-navicon-round" fixed-width="false"></ons-icon></ons-toolbar-button>
</div>
<div class="right">
<ons-toolbar-button ng-click="collapse()" ><ons-icon icon="ion-android-search"></ons-icon></ons-toolbar-button>
</div>
<div class="center">Alojamientos</div>
</ons-toolbar>
<div class="searchbar">
<input ng-show="collapsed" type="search" class="search-input" ng-model="search" placeholder="Buscar">
</div>
<div class="app-page alojamientos-page">
<ons-list modifier="news">
<ons-list-item modifier="chevron" class="list-item-container" ng-repeat="item in items | filter:search" ng-click="showPost(item)">
<ons-row>
<div class="thumbnail-box is-loading" images-loaded="imgLoadedEvents">
<img ng-show="{{ item.thumbnail_images }}" ng-src="{{ item.thumbnail_images.full.url }}" class="thumbnail" img-cache>
</div>
</ons-row>
<ons-row>
<div class="cabecera">
<div class="name">
{{ item.title | limitTo: 25 }}
</div>
<div class="location" ng-show="{{ item.categories }}">
</div>
</div>
</ons-row>
</ons-list-item>
</ons-list>
<ons-button id="moreButton" modifier="large" should-spin="{{isFetching}}" ng-click="nextPage()">more news</ons-button>
</div>
</ons-page>
app.js
$scope.collapsed = false;
$scope.collapse = function(){
return $scope.collapsed=!$scope.collapsed;
}
web example in "alojamientos" menu item: http://recorramisiones.com.ar/rutadelaselva/app2/
Thanks a lot
If you really want to put it into the toolbar, I think it should be inside one of the three position classes, something like this:
<div class="center">Alojamientos
<div class="searchbar" style="position:absolute; left:0; right:0">
<input ng-show="collapsed" type="search" class="search-input" ng-model="search" placeholder="Buscar">
</div>
</div>
Then you can use ng-style or ng-class to increase and decrease the height of the toolbar when you show or hide the searchbar and change anything else you need.
Another possibility would be to give to your searchbar's div the appearance of the toolbar with class="navigation-bar searchbar", and then delete the bottom border of the actual toolbar and adjust anything you need.

Resources