I'm using slack responsive carousel to show items this items comes from array $ctrl.items and I'm using ng-repeat inside this slack carousel till now It works fine
the problem is when I click on a any button which changes the items inside $ctrl.items array
slack starts to view the items vertically and if i changed the screen width to smaller or larger screen the problem disappears and the slider works fine again
<slick
dots="true"
infinite="false"
speed="300"
slides-to-show="3"
slides-to-scroll="3"
responsive="[{
breakpoint: 1024,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
infinite: true,
dots: true
}
},
{
breakpoint: 600,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
}]"
>
<div ng-repeat="item in $ctrl.items">
<div class="thumbnail">
<h6>category</h6>
<h4>{{item.name}}</h4>
<img src="http://placehold.it/300x200/" alt="Slide11" />
<h6>
{{item.price}} €
<i class="fas fa-cart-arrow-down gray"></i>
</h6>
</div>
</div>
</slick>
this solved the problem
For change slide content, you have to set ng-if to destroy and init it
controller:
$scope.number = [{label: 1}, {label: 2}, {label: 3}, {label: 4}, {label: 5}, {label: 6}, {label: 7}, {label: 8}];
$scope.numberLoaded = true;
$scope.numberUpdate = function(){
$scope.numberLoaded = false; // disable slick
//number update
$scope.numberLoaded = true; // enable slick
};
Related
I am trying to use angular gridster to have charts inside them. Below is the code which I am using. First thing is it doesnt allow me to move or resize any of these grids. Second its making each chart inside the grid repeat 4 times . Can anyone let me know what I could be doing wrong with the html or the configuration for gridster. I have referenced the css and js files for it correctly.
$scope.standardItems = [{
size: {
x: 2,
y: 2
},
position: [0, 0]
},
{
size: {
x: 2,
y: 2
},
position: [2, 0]
},
{
size: {
x: 2,
y: 3
},
position: [0, 2]
},
{
size: {
x: 1,
y: 1
},
position: [4, 2]
}
];
$scope.gridsterOpts = {
minRows: 2, // the minimum height of the grid, in rows
maxRows: 5,
columns: 1, // the width of the grid, in columns
colWidth: 'auto', // can be an integer or 'auto'. 'auto' uses the pixel width of the element divided by 'columns'
rowHeight: 'match', // can be an integer or 'match'. Match uses the colWidth, giving you square widgets.
margins: [10, 10], // the pixel distance between each widget
defaultSizeX: 2, // the default width of a gridster item, if not specifed
defaultSizeY: 1, // the default height of a gridster item, if not specified
minSizeX: 1, // minimum column width of an item
maxSizeX: null, // maximum column width of an item
minSizeY: 1, // minumum row height of an item
maxSizeY: null, // maximum row height of an item
isMobile: true, // stacks the grid items if true
mobileBreakPoint: 600, // if the screen is not wider that this, remove the grid layout and stack the items
mobileModeEnabled: true, // whether or not to toggle mobile mode when screen width is less than mobileBreakPoint
resizable: {
enabled: true,
start: function(event, uiWidget, $element) {}, // optional callback fired when resize is started,
resize: function(event, uiWidget, $element) {}, // optional callback fired when item is resized,
stop: function(event, uiWidget, $element) {} // optional callback fired when item is finished resizing
},
draggable: {
enabled: true, // whether dragging items is supported
handle: 'h5', // optional selector for resize handle
start: function(event, uiWidget, $element) {}, // optional callback fired when drag is started,
drag: function(event, uiWidget, $element) {}, // optional callback fired when item is moved,
stop: function(event, uiWidget, $element) {} // optional callback fired when item is finished dragging
}
};
<div gridster="gridsterOpts">
<ul>
<li style="border: solid 1px;" gridster-item="item" ng-repeat="item in standardItems">
<div class="container-fluid">
<div class="row">
<div class="col-md-4">
<h5>{{charts.data.chartsName[$parent.$index]}}</h5>
</div>
<div class="field-container" style="margin-top: 10px;">
<select class="form-control col-md-4" ng-change="charts.hasChanged[arrKey]" ng-model="charts.type[arrKey]" ng-init="charts.type[arrKey] = charts.data.chartsDefault[$parent.$index]">
<option ng-repeat="chartsTypeValue in charts.data.chartsType[arrKey] " >{{chartsTypeValue}}</option>
</select>
<!-- <label class="floating-label">Chart Type</label> -->
</div>
</div>
</div>
<div class="svg-container" ng-if="charts.type[arrKey] =='Bar'" style="width: 400px; height: 250px;">
<bars-chart ng-if="arrValue" chart-data="arrValue" />
</div>
<div class="svg-container " ng-if="charts.type[arrKey] =='Pie'" style="text-align: -webkit-center; width: 400px; height: 220px; ">
<donut-Chart ng-if="arrValue" chart-data="arrValue">
</donut-chart>
</div>
<div class="svg-container " ng-if="charts.type[arrKey]=='Line'" style="width: 400px; height: 220px; ">
<line-Chart ng-if="arrValue" chart-data="arrValue">
</line-chart>
</div>
<hr>
</li>
</ul>
</div>
</div>
I am fetching some records which are already assigned to users with checked checkboxes. I want to assign some additional ones that are coming as unchecked checkboxes. How can I show checked checkboxes first and then show whatever is unchecked after them?
You can use angular filters to show checked checkboxes first and whatever is unchecked, show it after them
try this:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.data = [
{id: 1, value: 1},
{id: 2, value: 0},
{id: 3, value: 1},
{id: 4, value: 0},
{id: 5, value: 0}
];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="myApp">
<div ng-controller="myCtrl">
<h2>Checked</h2>
<div ng-repeat="item in data | filter : { value : 1}">
{{item.id}} : <input type="checkbox" ng-checked="item.value=='1'"/>
</div>
<h2>Unchecked</h2>
<div ng-repeat="item in data | filter : { value : 0}">
{{item.id}} : <input type="checkbox" ng-checked="item.value=='1'"/>
</div>
</div>
</div>
Hope it helps..
I am creating typeahead for dropdown. I used angularjs-typeahead-dropdown.min . But its not working. Below is my code
<head>
<script src="src/angular.min.js"></script>
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="Typeahead.js"></script>
<script src="src/angularjs-typeahead-dropdown.min.js"></script>
<title></title>
</head>
<div class="container">
<typeahead-dropdown id="ex1" ng-model="ex1model" options="ex1data" config="ex1config"></typeahead-dropdown>
</div>
in js file
$scope.ex1model = [];
$scope.ex1data = [{ id: 1, label: "Tony" },
{ id: 2, label: "Larita" },
{ id: 3, label: "Brian" },
{ id: 4, label: "Andrew" },
{ id: 5, label: "Bruno" },
{ id: 6, label: "Adrian" },
{ id: 7, label: "Stuart" },
{ id: 8, label: "Stephen" },
{ id: 9, label: "Peter" },
{ id: 10, label: "Alexander" }];
$scope.ex1config = { modelLabel: "id", optionLabel: "label" };
This is not working. Nothing comes in html page. Please tell me how to implement typeahead for dropdown. Is there any other way. I should not use jquery
You can use UI Bootstrap's Dropdown on an input box as follows
<div uib-dropdown>
<input type="text" ng-model="searchKey" uib-dropdown-toggle>
<ul uib-dropdown-menu>
<li ng-repeat="data in ex1data | filter:searchKey">
{{data.label}}
</li>
</ul>
</div>
Check the documentation for UI Bootstrap dropdown here
i would recommend to use select2
this link will make u learn how to use it from scratch
select2 for beginner
this link will make you realise why to use it
just have a look
Examples for select2
I have multiple tabs and each is having angular ui-grid inside it. Each grid should display different data. But i'm facing problem like in one tab data is coming in the grid on page load but in another tab ui-grid itself is not loading. Not getting what is the problem. Please help.
Below is the sample of the code:
<uib-tabset class="nav">
<uib-tab heading="User">
<div ng-include="'./public/partials/tabs/user.html'">
</div>
</uib-tab>
<uib-tab heading="Notes">
<div ng-include="'./public/partials/tabs/notifications.html'">
</div>
</uib-tab>
<uib-tab heading="Assets">
<div ng-include="'./public/partials/tabs/assetsList.html'"></div>
</uib-tab>
<uib-tab heading="Audit Logs">
<div ng-include="'./public/partials/tabs/audit.html'" >
</div>
</uib-tab>
</uib-tabset>
Html for tabs:
<div class="container-fluid">
<form name="assetsForm" novalidate class="form-horizontal">
<div class='container-fluid containerborder'>
<br>
<!--creating table-->
<div data-ui-grid="assetsOptions" data-ui-grid-pagination></div>
</div>
</form>
</div>
<div class="container-fluid">
<form name="userForm" novalidate class="form-horizontal">
<div class='container-fluid containerborder'>
<br>
<!--creating table-->
<div data-ui-grid="userOptions" data-ui-grid-pagination></div>
</div>
</form>
</div>
Controller part:
$scope.data = [
{ name: 'Alex', car: 'Toyota' },
{ name: 'Sam', car: 'Lexus' },
{ name: 'Joe', car: 'Dodge' },
{ name: 'Bob', car: 'Buick' },
{ name: 'Cindy', car: 'Ford' },
];
$scope.userOptions = {
data: 'data',
paginationPageSizes: [5, 10, 25],
paginationPageSize: 5,
columnDefs: [
{name: 'name'},
{name: 'car'}
]
};
$scope.assetsData = [
{ table: 'Brian', class: 'Audi' },
{ table: 'Malcom', class: 'Mercedes Benz' },
{ table: 'Dave', class: 'Ford' },
{ table: 'Stacey', class: 'Audi' },
{ table: 'Amy', class: 'Acura' },
{ table: 'Scott', class: 'Toyota' },
{ table: 'Ryan', class: 'BMW' },
];
$scope.assetsOptions = {
data: 'data',
paginationPageSizes: [5, 10, 25],
paginationPageSize: 5,
columnDefs: [
{name: 'table'},
{name: 'class'}
]
};
If one grid is loading on page load and others are not, it basically means A) other tabs are not initialized on page load B) grid initializing code should be in tab switch instead of page load C) file or data is not available at specified location.
I hope this will help.
Hi I have an issue with my slick slider plugin.
I want to have 4 slides in one (2 rows, 2 slides for row) - in the size > 768px, if I have a width < 768px I want to have one slide. My structure looks like:
<div class="gallery-slider">
<div class="gallery-box"></div>
<div class="gallery-box"></div>
<div class="gallery-box"></div>
<div class="gallery-box"></div>
<div class="gallery-box"></div>
<div class="gallery-box"></div>
</div>
My JS code looks like:
$('.gallery-slider').slick({
dots: true,
infinite: false,
speed: 300,
rows: 2,
slidesPerRow: 2,
responsive: [
{
breakpoint: 768,
settings: {
rows: 1,
slidesPerRow: 1
}
},
]
});
Why my mobile view not work,
What can I do in this situation?