bootstrap navbar menu dropdown not working - angularjs

I have a MEAN app generated by yeoman angular-fullstack that I have been trying to modify. I want to add a tab to the navigation bar, which upon clicking, will show additional items in a drop down.
Something like this:
http://getbootstrap.com/examples/navbar/
Here is my navbar.html file:
<div class="navbar navbar-default navbar-fixed-top" ng-controller="NavbarController">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggle" data-toggle="collapse" data-target="#navbar-main" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<b>Cassmon</b>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-collapse collapse" id="navbar-main">
<ul class="nav navbar-nav">
<li ng-repeat="item in nav.menu" ng-class="{active: nav.isActive(item.link)}">
<a ng-href="{{item.link}}">{{item.title}}</a>
</li>
<li class="dropdown">
Metric Browser<span class="caret"></span>
<ul class="dropdown-menu" collapse="nav.isCollapsed()">
<li>Latency </li>
<li>Performance </li>
<li>Execution </li>
<li>All </li>
</ul>
</li>
</ul>
</div>
</div>
</div>
And here is my navbar.controller.ts file:
'use strict';
class NavbarController {
//start-non-standard
menu = [{
'title': 'Home',
'link': '/'
},{
'title': 'Dropdown',
'link' : '/dropdown'
}];
$location;
Auth;
isAdmin;
getCurrentUser;
isLoggedIn;
isCollapsed = false;
//end-non-standard
constructor($location, Auth) {
this.$location = $location;
this.isLoggedIn = Auth.isLoggedIn;
this.isAdmin = Auth.isAdmin;
this.getCurrentUser = Auth.getCurrentUser;
}
isActive(route) {
return route === this.$location.path();
}
isCollapsed() {
return this.isCollapsed;
}
toggleCollpase() {
if (this.isCollapsed) {
this.isCollapsed = false;
} else {
this.isCollapsed = true;
}
}
}
angular.module('cassmonApp')
.controller('NavbarController', NavbarController);
When I build the app, I get this page but when I click the drowdown button I don't see the menu coming up. Any help would be appreciated.
Here are my package files:
bower.json
{
"name": "XXXXXXXX",
"version": "0.0.0",
"dependencies": {
"angular": "~1.5.0",
"json3": "~3.3.1",
"es5-shim": "~3.0.1",
"bootstrap": "~3.1.1",
"bootstrap-social": "~4.9.1",
"angular-resource": "~1.5.0",
"angular-cookies": "~1.5.0",
"angular-sanitize": "~1.5.0",
"angular-route": "~1.5.0",
"angular-bootstrap": "~1.1.2",
"font-awesome": ">=4.1.0",
"lodash": "~2.4.1",
"angular-socket-io": "~0.7.0",
"angular-validation-match": "~1.5.2",
"bootstrap-side-navbar": "^1.0.1",
"angular-datatables": "^0.5.4",
"angular-daterangepicker": "^0.2.2",
"angular-material": "^1.1.0",
"angular-messages": "^1.5.8",
"angular-chart.js": "^1.0.3"
},
"devDependencies": {
"angular-mocks": "~1.5.0"
}
}
package.json
{
"name": "XXXXXXXX",
"version": "0.0.0",
"main": "server/app.js",
"dependencies": {
"babel-polyfill": "^6.7.2",
"babel-runtime": "^6.6.1",
"bluebird": "^3.3.3",
"body-parser": "^1.13.3",
"composable-middleware": "^0.3.0",
"compression": "^1.5.2",
"connect-mongo": "^1.2.1",
"cookie-parser": "^1.3.5",
"dateformat": "^1.0.12",
"ejs": "^2.3.3",
"errorhandler": "^1.4.2",
"express": "^4.13.3",
"express-jwt": "^3.0.0",
"express-session": "^1.11.3",
"jsonwebtoken": "^7.0.0",
"lodash": "^4.6.1",
"lusca": "^1.3.0",
"method-override": "^2.3.5",
"mongoose": "^4.1.2",
"morgan": "~1.7.0",
"passport": "~0.3.0",
"passport-google-oauth20": "^1.0.0",
"passport-local": "^1.0.0",
"serve-favicon": "^2.3.0",
"socket.io": "^1.3.5",
"socket.io-client": "^1.3.5",
"socketio-jwt": "^4.2.0",
"uuid": "^3.0.0"
},
"devDependencies": {
"autoprefixer": "^6.0.0",
"babel-core": "^6.6.5",
"babel-register": "^6.6.5",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.6.0",
"del": "^2.0.2",
"gulp": "^3.9.1",
"gulp-add-src": "^0.2.0",
"gulp-angular-templatecache": "^1.7.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-babel": "^6.1.2",
"gulp-typescript": "~2.13.0",
"gulp-typings": "^1.3.6",
"gulp-tslint": "^5.0.0",
"gulp-cache": "^0.4.2",
"gulp-concat": "^2.6.0",
"gulp-env": "^0.4.0",
"gulp-filter": "^4.0.0",
"gulp-imagemin": "^2.2.1",
"gulp-inject": "^4.0.0",
"gulp-istanbul": "~0.10.3",
"gulp-istanbul-enforcer": "^1.0.3",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.0.0",
"jshint": "2.9.2",
"gulp-livereload": "^3.8.0",
"gulp-load-plugins": "^1.0.0-rc.1",
"gulp-clean-css": "^2.0.6",
"gulp-mocha": "^2.1.3",
"gulp-ng-annotate": "^2.0.0",
"gulp-ng-constant": "^1.1.0",
"gulp-node-inspector": "^0.1.0",
"gulp-plumber": "^1.0.1",
"gulp-protractor": "^2.1.0",
"gulp-rename": "^1.2.2",
"gulp-rev": "^7.0.0",
"gulp-rev-replace": "^0.4.2",
"gulp-sort": "^2.0.0",
"gulp-sourcemaps": "^1.5.2",
"gulp-svgmin": "^1.1.2",
"gulp-uglify": "^1.2.0",
"gulp-useref": "^3.0.3",
"gulp-util": "^3.0.5",
"gulp-watch": "^4.3.5",
"grunt": "^1.0.1",
"grunt-build-control": "^0.7.0",
"isparta": "^4.0.0",
"utile": "~0.3.0",
"nodemon": "^1.3.7",
"run-sequence": "^1.1.0",
"lazypipe": "^1.0.1",
"wiredep": "^2.2.2",
"open": "~0.0.4",
"jshint-stylish": "^2.2.0",
"connect-livereload": "^0.5.3",
"istanbul": "~0.4.1",
"chai": "^3.2.0",
"sinon": "^1.16.1",
"chai-as-promised": "^5.1.0",
"chai-things": "^0.2.0",
"karma": "~0.13.3",
"karma-firefox-launcher": "^1.0.0",
"karma-script-launcher": "^1.0.0",
"karma-chrome-launcher": "^1.0.1",
"karma-jade-preprocessor": "0.0.11",
"karma-phantomjs-launcher": "~1.0.0",
"karma-ng-html2js-preprocessor": "^1.0.0",
"karma-spec-reporter": "~0.0.20",
"sinon-chai": "^2.8.0",
"mocha": "^2.2.5",
"karma-mocha": "^1.0.1",
"karma-chai-plugins": "~0.7.0",
"phantomjs-prebuilt": "^2.1.4",
"proxyquire": "^1.0.1",
"supertest": "^1.1.0",
"tslint": "^3.5.0",
"typings": "^0.8.1"
},
"engines": {
"node": "^4.4.0",
"npm": "^2.14.20"
},
"scripts": {
"test": "gulp test",
"postinstall": "./node_modules/.bin/typings install",
"update-webdriver": "node node_modules/protractor/bin/webdriver-manager update",
"start": "node server"
},
"private": true
}

please make sure that you have linked bootstrap.js and jquery.js files and sometime there is issue with jquery version.

Angular and bootstrap fight each other due to bootstraps dependency on jQuery. Right now angular-bootstrap is trying to reconcile the two using ui bootstrap.
<div ng-controller="DropdownCtrl">
<!-- Simple dropdown -->
<span uib-dropdown on-toggle="toggled(open)">
<a href id="simple-dropdown" uib-dropdown-toggle>
Click me for a dropdown, yo!
</a>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="simple-dropdown">
<li ng-repeat="choice in items">
<a href>{{choice}}</a>
</li>
</ul>
</span>
</div>
Is from http://angular-ui.github.io/bootstrap/ This is where I would look for solutions.

If you are using angular cli you can:
first: npm install bootstrap#next
//install jquery, etc, too.
Then put this in your file angular-cli.json:
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"styles.css"
],
"scripts": [
"../node_modules/bootstrap/dist/js/bootstrap.js",
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js"
],

Related

Angularjs angular-ui-ace editor tab key not working and misspelled options

Issues:
When I set ace editor to html mode the tab key no longer tabs.
When I try and set options I get the following error message/s
misspelled option "enableLiveAutocompletion"
misspelled option "enableEmmet"
My bower.json looks like this
{
"name": "fountain-inject",
"version": "0.0.1",
"dependencies": {
"jquery": "^3.1.0",
"angular": "^1.5.0",
"angular-ui-router": "^0.3.1",
"angular-dragula": "^1.2.7",
"medium-editor": "^5.21.0",
"angular-ui-ace": "bower"
},
"overrides": {
"ace-builds": {
"main": ["src-noconflict/ace.js",
"src-noconflict/ext-language_tools.js",
"src-noconflict/theme-monokai.js",
"src-noconflict/mode-html.js",
"src-noconflict/ext-emmet.js"
]
},
"devDependencies": {
"angular-mocks": "^1.5.0"
}
}
}
and my code looks like this
_editor.setTheme("ace/theme/monokai");
_editor.getSession().setMode("ace/mode/html");
_editor.getSession().setOptions({
"enableBasicAutocompletion": true,
"enableSnippets": true,
"enableLiveAutocompletion": false,
"enableEmmet": true
});
And my html (which is a 'view')
<div class='parent' ng-controller='Main'>
<div class='wrapper'>
<div class='container' dragula='"fifth-bag"'>
<div data-type="a">A</div>
<div data-type="b">B</div>
<div data-type="c">C</div>
</div>
<div id="dragulaCopyWithSort" class='container' dragula='"fifth-bag"'>
</div>
<div ui-ace="{
onLoad: aceLoaded,
onChange: aceChanged
}">ace</div>
</div>

Tool bar display issue in text-angular directive

I am using textAngular Directive to implement HTML editor in my application.
I have followed all the steps mentioned in there wiki (In Git repository).
I used bower to installed textAngular.
Folling are my code snippets
bower.json
{
"name": "Appname",
"version": "0.0.0",
"dependencies": {
"angular": "^1.3.0",
"json3": "^3.3.0",
"es5-shim": "^4.0.0",
"bootstrap": "^3.2.0",
"angular-animate": "^1.3.0",
"angular-aria": "^1.3.0",
"angular-cookies": "^1.3.0",
"angular-messages": "^1.3.0",
"angular-resource": "^1.3.0",
"angular-route": "^1.3.0",
"angular-sanitize": "^1.3.0",
"angular-touch": "^1.3.0",
"highcharts": "~4.0.4",
"bootstrap-calendar": "~0.2.4",
"smalot-bootstrap-datetimepicker": "~2.3.1",
"angular-datatables": "~0.3.0",
"components-font-awesome": "~4.3.0",
"angular-filter": "~0.5.1",
"datatables-responsive": "~1.0.2",
"datatables-colvis": "~1.1.1",
"textAngular": "~1.3.0",
"angularjs-dropdown-multiselect": "^1.5.2",
"lodash": "^3.5.0",
"angular-bootstrap-switch": "0.3.0",
"angular-toggle-switch": "~1.2.1",
"ngImgCrop": "~0.3.2",
"angular-file-upload": "~1.1.5"
},
"devDependencies": {
"angular-mocks": "~1.3.0",
"angular-scenario": "~1.3.0",
"rangy-core":"~1.2.3",
"rangy-saveselection":"~1.2.3"
},
"appPath": "app"
}
Index.html
CSS:
<link rel="stylesheet" href="bower_components/textAngular/src/textAngular.css" /
Scripts :
<script src="bower_components/rangy/rangy-core.min.js"></script>
<script src="bower_components/rangy/rangy-cssclassapplier.min.js"></script>
<script src="bower_components/rangy/rangy-selectionsaverestore.min.js"></script>
<script src="bower_components/rangy/rangy-serializer.min.js"></script>
<script src="bower_components/textAngular/src/textAngular.js"></script>
<script src="bower_components/textAngular/src/textAngularSetup.js"></script>
HTML code :
<div class="col-xs-12 col-sm-6 col-lg-6">
<text-angular ng-model="htmlVariable"></text-angular>
</div>
Please help me in finding what I am doing wrong
Regards
Mahesh
It my bad,
made mistake in application css
.btn-default{
width: 100%;
}
tool bar is using btn-defalt class

ng-repeat variable scope to the DOM block

Am I dreaming or I really saw that somewhere, but I can't remember the exact syntax. So if I have
var fooObjects = [{ name:"John", age:15 },
{ name: "Michael", age:26 },
...etc...]
and
<div ng-repeat="for foo in fooObjects"> <-- note, this isn't real syntax
{{name}} <-- Now you don't have to explicitly call `foo.name`
{{age}} inside of this div block
</div>
An example from https://docs.angularjs.org/api/ng/directive/ngRepeat. Try something like this:
<div ng-init="friends = [
{name:'John', age:25, gender:'boy'},
{name:'Jessie', age:30, gender:'girl'},
{name:'Johanna', age:28, gender:'girl'},
{name:'Joy', age:15, gender:'girl'},
{name:'Mary', age:28, gender:'girl'},
{name:'Peter', age:95, gender:'boy'},
{name:'Sebastian', age:50, gender:'boy'},
{name:'Erika', age:27, gender:'girl'},
{name:'Patrick', age:40, gender:'boy'},
{name:'Samantha', age:60, gender:'girl'}
]">
<ul>
<li ng-repeat="friend in friends">
{{friend.name}} who is {{friend.age}} years old.
</li>
</ul>
</div>
Here's a plunker with the example http://plnkr.co/edit/I19oBk20T5ldLZe7GYqN?p=preview
--edit--
I misunderstood your earlier question. You could go about aliasing the variable in the ng-repeat by implementing the following in your controller:
$scope.scopify(scope, object) {
for (var o in object) {
scope[o] = object[o];
}
}
Used like the following:
<li ng-repeat="friend in friends" ng-init="scopify(this, friend)">
{{name}}, {{age}}, {{gender}}
</li>
Here is a plunker with a working example: http://plnkr.co/edit/Y8c4uOagcdM5cXN81TET?p=preview
In addition to the above example, you can create aliases for any of the properties of an object through the ng-init directive. For example, another possible solution could be this:
<li ng-repeat="friend in friends"
ng-init="name = friend.name; age = friend.age; gender = friend.gender">
{{name}}, {{age}}, {{gender}}
</li>
We can use ng-init to create aliases that we can reference in that html block. While this is not very useful if you are only going to reference each property once, it might come in handy if you have to repeat the same property multiple times within a block of html.

does ng-repeat create multiple instances of a variable?

I've created this plunker in the form of a 'ToDo' list. My purpose is to fulfill just what it looks like.
Click an item and it will become 'marked' complete. However I am seeing a weird occurrence happen and that is when I change the 'visible' variable to true or false on click, it only effects the list item in the ng-repeat. Conversely, in my 'ToDo' list without ng-repeat the behavior works as expected (though not as desired).
Why does it function this way?
(also the select element at the bottom would work, however it breaks the 'marking complete' by switching the value of 'visible' when I don't actually want it to, any ideas on that would be helpful as well)
http://plnkr.co/edit/uiirZNV5yyBuB5XLst6y?p=preview
<h2>using ng-repeat:</h2>
<div ng-init="peeps = [
{name:'John', age:25, gender:'boy'},
{name:'Jessie', age:30, gender:'girl'},
{name:'Johanna', age:28, gender:'girl'},
{name:'Joy', age:15, gender:'girl'},
{name:'Mary', age:28, gender:'girl'},
{name:'Peter', age:95, gender:'boy'},
{name:'Sebastian', age:50, gender:'boy'},
{name:'Erika', age:27, gender:'girl'},
{name:'Patrick', age:40, gender:'boy'},
{name:'Samantha', age:60, gender:'girl'}
]"></div>
<ul ng-init="visible = true">
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}" ng-repeat="peep in peeps">{{peep.name}}</li>
</ul>
<h2>NOT using ng-repeat:</h2>
<div>
<ul ng-init="visible = true">
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}">{{peeps[0].name}}</li>
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}">{{peeps[1].name}}</li>
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}">{{peeps[2].name}}</li>
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}">{{peeps[3].name}}</li>
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}">{{peeps[4].name}}</li>
<li ng-click="visible = !visible" ng-class="{'strike': !visible, 'none': visible}">{{peeps[5].name}}</li>
</ul>
this is because ng-repeat creates its own scope for each item,
you need to access parent scope via $parent
ng-repeat also gives you access to elemnt index in the array,
so your code may look like
ng-repeat="(i, peep) in peeps"
...
ng-click="$parent.peeps[i].visible = !$parent.peeps[i].visible"

AngularJS: Custom Sorting Function using OrderBy

I am attempting to define my own sorting function using the documentation provided at http://docs.angularjs.org/api/ng.filter:orderBy.
Before I explain the code written, I will also mention the behaviour that I am expecting.
I have a table which contains a table header(th) and table data(td). When the user clicks on a column in the table (by column, I mean the th), the table data must sort based on the value in that column.
If the user clicks the same column again, then the sorting is changed to ascending / descending if the previous sorting criteria was descending / ascending respectively.
The user can sort using multiple columns. The first column selected is give the first priority. In case the first column value is the same, then the second column selected for sorting is used.
Now for the code. It can be found here: http://jsfiddle.net/xkjmv/
Problem is that the customSortFunction returns the array as expected, but the sorting does not work - when the user clicks on the column header, the sorting should be either ascending or descending (basically toggle each time it is clicked).
I want to return an array of string predicates since I will have multiple columns to sort, but a single column sort using string predicate itself is not working
EDIT: You can check the console to see the output that the custom sort function returns, if it is not obvious from the code.
In this plunker you can find an example of what you'r looking for with other stuff, hope this help.
Update:
As blazemonger requested the code:
Controllers.js:
app.controller('ctrlRead', ['$scope', '$filter', 'Items', function($scope, $filter, Items) {
// init
$scope.sortingOrder = sortingOrder;
$scope.reverse = false;
$scope.filteredItems = [];
$scope.groupedItems = [];
$scope.itemsPerPage = 5;
$scope.pagedItems = [];
$scope.currentPage = 0;
//#####################################
// get the items from the Items service
Items.then(function(data){
$scope.items = data;
$scope.search();
});
//#####################################
var searchMatch = function (haystack, needle) {
if (!needle) {
return true;
}
return haystack.toLowerCase().indexOf(needle.toLowerCase()) !== -1;
};
// init the filtered items
$scope.search = function () {
$scope.filteredItems = $filter('filter')($scope.items, function (item) {
for(var attr in item) {
if (searchMatch(attr, $scope.query)){
return true;
}
}
return false;
});
// take care of the sorting order
if ($scope.sortingOrder !== '') {
$scope.filteredItems = $filter('orderBy')($scope.filteredItems, $scope.sortingOrder, $scope.reverse);
}
$scope.currentPage = 0;
// now group by pages
$scope.groupToPages();
};
// calculate page in place
$scope.groupToPages = function () {
$scope.pagedItems = [];
for (var i = 0; i < $scope.filteredItems.length; i++) {
if (i % $scope.itemsPerPage === 0) {
$scope.pagedItems[Math.floor(i / $scope.itemsPerPage)] = [ $scope.filteredItems[i] ];
} else {
$scope.pagedItems[Math.floor(i / $scope.itemsPerPage)].push($scope.filteredItems[i]);
}
}
};
$scope.range = function (start, end) {
var ret = [];
if (!end) {
end = start;
start = 0;
}
for (var i = start; i < end; i++) {
ret.push(i);
}
return ret;
};
$scope.prevPage = function () {
if ($scope.currentPage > 0) {
$scope.currentPage--;
}
};
$scope.nextPage = function () {
if ($scope.currentPage < $scope.pagedItems.length - 1) {
$scope.currentPage++;
}
};
$scope.setPage = function () {
$scope.currentPage = this.n;
};
// change sorting order
$scope.sort_by = function(newSortingOrder) {
if ($scope.sortingOrder == newSortingOrder){
$scope.reverse = !$scope.reverse;
}
$scope.sortingOrder = newSortingOrder;
// icon setup
$('th i').each(function(){
// icon reset
$(this).removeClass().addClass('icon-sort');
});
if ($scope.reverse){
$('th.'+newSortingOrder+' i').removeClass().addClass('icon-chevron-up');
}else{
$('th.'+newSortingOrder+' i').removeClass().addClass('icon-chevron-down');
}
};
}]);
app.js:
var app = angular.module('plunker', []);
items.json:
[
{
"ProgramCode":"3DS",
"ProgramGroup":"NCIM",
"EventCode":"20130424TX3DS",
"StartDate":"2013-04-22 00:00:00",
"FormalDate":"April 22-24, 2013",
"LocCity":"Richardson",
"LocState":"TX",
"LocAddress":"3400 Waterview Parkway, #200",
"LocName":"America First Insurance Company",
"Price":"0.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"1",
"LocLatitude":"32.9695",
"LocLongitude":"-96.7409",
"EventType":"SSIH",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Richardson, TX",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"PA",
"ProgramGroup":"CISR",
"EventCode":"20130422SDPA",
"StartDate":"2013-04-22 00:00:00",
"FormalDate":"April 22, 2013",
"LocCity":"Rapid City",
"LocState":"SD",
"LocAddress":"445 Mt. Rushmore Road",
"LocName":"Adoba Eco Hotel Rapid City \/ Mt. Rushmore",
"Price":"150.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"19",
"LocLatitude":"44.0853",
"LocLongitude":"-103.213",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Rapid City, SD",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"RME",
"ProgramGroup":"CRM",
"EventCode":"20130425FLRME",
"StartDate":"2013-04-22 00:00:00",
"FormalDate":"April 22-25, 2013",
"LocCity":"Orlando",
"LocState":"FL",
"LocAddress":"8101 World Center Dr.",
"LocName":"Caribe Royale",
"Price":"430.00",
"LicenseeURL":"http:\/\/www.faia.com\/PV\/Core\/Events\/Events.aspx",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"32",
"LocLatitude":"28.3916",
"LocLongitude":"-81.4734",
"EventType":"LSIHOERS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Orlando, FL",
"cls":""
},
{
"ProgramCode":"ALM",
"ProgramGroup":"CISR",
"EventCode":"20130423MNALM",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Shoreview",
"LocState":"MN",
"LocAddress":"1000 Gramsie Road",
"LocName":"Hampton Inn",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.iiaba.net\/MN\/03_Education\/01_Calender\/NAV_EDUCalendar?ContentPreference=MN&ActiveState=MN&ActiveTab=NA&ContentLevel1=EDUCTN&ContentLevel2=EDUCAL",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"40",
"LocLatitude":"45.0856",
"LocLongitude":"-93.1353",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Shoreview, MN",
"cls":""
},
{
"ProgramCode":"AO",
"ProgramGroup":"CISR",
"EventCode":"20130423ILAO",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Bannockburn",
"LocState":"IL",
"LocAddress":"1500 South Lakeside Drive",
"LocName":"Mesirow Financial",
"Price":"0.00",
"LicenseeURL":"https:\/\/protech.piiai.org\/Events\/CalendarEventsListView.aspx",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"40",
"LocLatitude":"42.1693",
"LocLongitude":"-87.8656",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Bannockburn, IL",
"cls":""
},
{
"ProgramCode":"AO",
"ProgramGroup":"CISR",
"EventCode":"20130423TXAO",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Richardson (North Dallas)",
"LocState":"TX",
"LocAddress":"900 East Lookout Drive",
"LocName":"Renaissance Dallas-Richardson Hotel",
"Price":"169.00",
"LicenseeURL":"http:\/\/www.iiah.org\/displaycommon.cfm?an=1&SUBARTICLENBR=228",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"16",
"LocLatitude":"32.9934",
"LocLongitude":"-96.659",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Richardson (North Dallas), TX",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"FUN",
"ProgramGroup":"CSRM",
"EventCode":"20130423CAFUN",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"San Bernardino",
"LocState":"CA",
"LocAddress":"1950 S. Sunwest Lane, Suite 102",
"LocName":"SCS JPA Conference Center",
"Price":"179.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"16",
"LocLatitude":"34.0807",
"LocLongitude":"-117.274",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"San Bernardino, CA",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"IP",
"ProgramGroup":"CISR",
"EventCode":"20130423MAIP",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Peabody",
"LocState":"MA",
"LocAddress":"43 Newbury Street",
"LocName":"Springhill Suites by Marriott",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.massagent.com\/education\/cisr.cfm",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"27",
"LocLatitude":"42.534",
"LocLongitude":"-70.9615",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Peabody, MA",
"cls":""
},
{
"ProgramCode":"IP",
"ProgramGroup":"CISR",
"EventCode":"20130423MIIP",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Troy",
"LocState":"MI",
"LocAddress":"2601 West Big Beaver Road",
"LocName":"Somerset Inn",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.michagent.org\/eweb\/DynamicPage.aspx?Site=AgentNet2&WebKey=2847b6dd-e47d-40ea-b5d1-504c5ff0f800",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"46",
"LocLatitude":"42.5635",
"LocLongitude":"-83.1841",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Troy, MI",
"cls":""
},
{
"ProgramCode":"PA",
"ProgramGroup":"CISR",
"EventCode":"20130423CAPA",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Santa Clara (San Jose)",
"LocState":"CA",
"LocAddress":"5201 Great America Parkway",
"LocName":"Network Meeting Center",
"Price":"169.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"17",
"LocLatitude":"37.3932",
"LocLongitude":"-121.961",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Santa Clara (San Jose), CA",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"PA",
"ProgramGroup":"CISR",
"EventCode":"20130423CTPA",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Middletown",
"LocState":"CT",
"LocAddress":"213 Court Street",
"LocName":"MiddleOak",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.pia.org\/EDU\/schedule.php?state=CT",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"40",
"LocLatitude":"41.5537",
"LocLongitude":"-72.6632",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Middletown, CT",
"cls":""
},
{
"ProgramCode":"PA",
"ProgramGroup":"CISR",
"EventCode":"20130423WVPA",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Charleston",
"LocState":"WV",
"LocAddress":"129 Summers Street",
"LocName":"Summit Conference Center",
"Price":"150.00",
"LicenseeURL":"http:\/\/www.ohiopia.com",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"4",
"LocLatitude":"38.3506",
"LocLongitude":"-81.6303",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Charleston, WV",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"PR",
"ProgramGroup":"CISR",
"EventCode":"20130423MEPR",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"South Portland",
"LocState":"ME",
"LocAddress":"363 Maine Mall Road",
"LocName":"DoubleTree by Hilton",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.massagent.com\/education\/cisr.cfm",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"10",
"LocLatitude":"43.6315",
"LocLongitude":"-70.2727",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"South Portland, ME",
"cls":""
},
{
"ProgramCode":"PR",
"ProgramGroup":"CISR",
"EventCode":"20130423MOPR",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Springfield",
"LocState":"MO",
"LocAddress":"2720 North Glenstone",
"LocName":"Holiday Inn Hotel and Suites",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.iiaa.org\/MO\/03_Education\/01_Calender\/NAV_EDUCalender?ContentPreference=MO&ActiveState=MO&ActiveTab=STATE&ContentLevel1=EDUCTN&ContentLevel2=EDUCAL",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"40",
"LocLatitude":"37.2571",
"LocLongitude":"-93.2902",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Springfield, MO",
"cls":""
},
{
"ProgramCode":"PR",
"ProgramGroup":"CISR",
"EventCode":"20130423NCPR",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Greensboro",
"LocState":"NC",
"LocAddress":"414 Gallimore Dairy Rd.",
"LocName":"BB&T Greensboro",
"Price":"0.00",
"LicenseeURL":"http:\/\/members.iianc.com\/wcm\/IIANC_Members\/Events\/List\/Core\/Events\/Events.aspx?hkey=90e5e7da-2e1f-4674-ae30-7c12ced0885c",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"16",
"LocLatitude":"36.0839",
"LocLongitude":"-79.9412",
"EventType":"LSIH",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Greensboro, NC",
"cls":""
},
{
"ProgramCode":"PR",
"ProgramGroup":"CISR",
"EventCode":"20130423NMPR",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Albuquerque",
"LocState":"NM",
"LocAddress":"2600 Louisiana, NE",
"LocName":"Sheraton Albuquerque Uptown",
"Price":"145.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"15",
"LocLatitude":"35.1064",
"LocLongitude":"-106.579",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Albuquerque, NM",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"PR",
"ProgramGroup":"CISR",
"EventCode":"20130423SDPR",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Rapid City",
"LocState":"SD",
"LocAddress":"445 Mt. Rushmore Road",
"LocName":"Adoba Eco Hotel Rapid City \/ Mt. Rushmore",
"Price":"150.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"18",
"LocLatitude":"44.0853",
"LocLongitude":"-103.213",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Rapid City, SD",
"cls":"LIMITED_SEATS"
},
{
"ProgramCode":"SR",
"ProgramGroup":"CISR",
"EventCode":"20130423ORSR",
"StartDate":"2013-04-23 00:00:00",
"FormalDate":"April 23, 2013",
"LocCity":"Portland",
"LocState":"OR",
"LocAddress":"8931 SE Foster Road Suite 200",
"LocName":"Assurety Northwest",
"Price":"0.00",
"LicenseeURL":"http:\/\/www.piawest.com\/calendar-of-events",
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"40",
"LocLatitude":"45.4786",
"LocLongitude":"-122.562",
"EventType":"LS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"Portland, OR",
"cls":""
},
{
"ProgramCode":"ADM",
"ProgramGroup":"CSRM",
"EventCode":"20130424CAADM",
"StartDate":"2013-04-24 00:00:00",
"FormalDate":"April 24, 2013",
"LocCity":"San Bernardino",
"LocState":"CA",
"LocAddress":"1950 S. Sunwest Lane, Suite 102",
"LocName":"SCS JPA Conference Center",
"Price":"179.00",
"LicenseeURL":null,
"GateKeeper_length":"0",
"GateKeeperHTML":null,
"SeatsAreAvailable":"18",
"LocLatitude":"34.0807",
"LocLongitude":"-117.274",
"EventType":"SS",
"LocationUnivURL":null,
"UnivCourseNumber":null,
"UnivCourseType":"",
"UnivFaculty":null,
"Course_Type":"San Bernardino, CA",
"cls":"LIMITED_SEATS"
}
]
service.js:
app.factory('Items', ['$http', function($http){
var Url = "items.json";
var Items = $http.get(Url).then(function(response){
return response.data;
});
return Items;
}]);
index.html:
<!doctype html>
<html ng-app="plunker">
<head>
<meta charset="utf-8">
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link
rel="stylesheet"
href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css"
>
<link rel="stylesheet" href="style.css">
<link
rel="stylesheet"
href="//netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css"
>
</head>
<body>
<script>
var sortingOrder = 'name';
</script>
<div ng-controller="ctrlRead">
<div class="input-append">
<input
type="text"
ng-model="query"
ng-change="search()"
placeholder="Search"
class="input-large search-query"
>
<span class="add-on"><i class="icon-search"></i></span>
</div>
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th class="LocName">
Id
<a ng-click="sort_by('LocName')">
<i class="icon-sort"></i>
</a>
</th>
<th class="Price">
Name
<a ng-click="sort_by('Price')">
<i class="icon-sort"></i>
</a>
</th>
<th class="Course_Type">
Description
<a ng-click="sort_by('Course_Type')">
<i class="icon-sort"></i>
</a>
</th>
<th class="cls">
Field 3
<a ng-click="sort_by('cls')">
<i class="icon-sort"></i>
</a>
</th>
<th class="SeatsAreAvailable">
Field 4
<a ng-click="sort_by('SeatsAreAvailable')">
<i class="icon-sort"></i>
</a>
</th>
<th class="StartDate">
Field 5
<a ng-click="sort_by('StartDate')">
<i class="icon-sort"></i>
</a>
</th>
</tr>
</thead>
<tfoot>
<td colspan="6">
<div class="pagination pull-right">
<ul>
<li ng-class="{disabled: currentPage == 0}">
<a href ng-click="prevPage()">« Prev</a>
</li>
<li
ng-click="setPage()"
ng-class="{active: n == currentPage}"
ng-repeat="n in range(pagedItems.length)"
>
<a href ng-bind="n + 1">1</a>
</li>
<li ng-class="{disabled: currentPage == pagedItems.length - 1}">
<a href ng-click="nextPage()">Next »</a>
</li>
</ul>
</div>
</td>
</tfoot>
<tbody>
<tr ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse">
<td>{{item.LocName}}</td>
<td>{{item.Price}}</td>
<td>{{item.Course_Type}}</td>
<td>{{item.cls}}</td>
<td>{{item.SeatsAreAvailable}}</td>
<td>{{item.StartDate}}</td>
</tr>
</tbody>
</table>
</div>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="http://code.angularjs.org/1.1.5/angular.js"></script>
<script src="app.js"></script>
<script src="controllers.js"></script>
<script src="services.js"></script>
</body>
</html>
Still a better approach will be to use the ng-grid module.

Resources