Error: [ng:areq] Argument 'detailsController' is not a function, got undefined - html

I am trying to display the artist details when he or she is selected from a list but the error i get in my chrome console says that detailsController is not a function got undefined
list.html
<section class="artist">
<div class="search">
<h1>Artist Directory</h1>
<label>Search:</label>
<input ng-model="query" type="text" placeholder="Search for artists" autofocus/>
<p> </p>
<label class="formgroup"> by:
<select ng-model="artistOrder">
<option value="name">Name</option>
<option value="reknown">Reknown</option>
</select>
</label>
<label class="formgroup">
<input type="radio" ng-model="direction" name="direction" checked/>ascending
</label>
<label class="formgroup">
<input type="radio" ng-model="direction" name="direction" value="reverse"/> descending
</label>
</div>
<ul class="artistlist">
<li class="artist cf" ng-repeat="artist in artists | filter: query | orderBy: artistOrder:direction">
<a href="#/details/{{artists.indexOf(artist)}}">
<img ng-src="images/{{artist.shortname}}_tn.jpg" alt=""/>
<div class="info">
<h2>{{artist.name }}</h2>
<h3>{{artist.reknown}}</h3>
</div>
</a>
</li>
</ul>
</section>
details.html
<section class="artistinfo">
<div class="artist cf" ng-model="artists">
<h1>{{artists[whichItem].name}}</h1>
<div class="info">
<h3>{{artists[whichItem].reknown}}</h3>
<img ng-src="images/{{artists[whichItem].shortname}}_tn.jpg" alt=""/>
<div class="bio">{{artists[whichItem].bio}}</div>
</div>
</div>
</section>
controllers.js
var artistControllers = angular.module('artistControllers', []);
artistControllers.controller('listController', ['$scope', '$http', function ($scope, $http) {
$http.get('js/data.json').success(function (data) {
$scope.artists = data;
$scope.artistOrder = "name"; // name is selected in orderby
});
}]);
artistControllers.controller('detailsController', ['$scope', '$http','$routeParams', function($scope, $http, $routeParams) {
$http.get('js/data.json').success(function(data) {
$scope.artists = data;
$scope.whichItem = $routeParams.itemId;
});
}]);
app.js
var myApp = angular.module('myApp',[
'ngRoute',
'artistControllers'
]);
myApp.config(['$routeProvider',function($routeProvider){
$routeProvider.when('/list', {
templateUrl: 'partials/list.html',
controller: 'listController'
}).
when('/details/:itemId', {
templateUrl:'partials/details.html',
controller:'detailsController'
}).
otherwise({
redirectTo: '/list'
});
}]);

Related

I want to show the data in another page

I want to take the id, name image and content of tinymce editor which i want to show on another page using controller. I am using array through which i want to take id, name, image and content but i don't know how to retrive it on another controller.
<div class="col-sm-4">
<div class="form-group">
<label class="settinglabel">Name</label>
<input type="text" maxlength="20" class="form-control" ng-model="data.name">
</div>
</div>
<div class="col-sm-3" style="margin-bottom: 4px;">
<div class="BoardCardWithCustomProperties BoardCardWithCustomProperties--hover" draggable="true">
<div class="BoardCardWithCustomProperties-contents">
<img class="BoardCardCoverImage" ng-src={{data.thumbnail}}>
<div class="BoardCardWithCustomProperties-nameAndDropdownButton">
</div>
</div>
</div>
</div>
<div id="design-9">
<div class="col-sm-12" style="margin-top:10px; margin-bottom:5px">
<textarea rows="20" cols="100" ui-tinymce="tinymceOptions" ng-model="tinymceModel" />
<input name="image" type="file" id="upload" class="hidden" onchange="">
</div>
</div>
myApp.controller('SampleFormatCntrl', ['$scope', '$http', 'orderProcessService', '$timeout', 'authService', '$routeParams', 'localStorageService', '$q', 'CommonhttpService', function ($scope, $http, orderProcessService, $timeout, authService, $routeParams, localStorageService, $q, CommonhttpService) {
var id = $routeParams.id;
$scope.data = localStorageService.get("formatdata");
$scope.action = $routeParams.action;
if ($scope.action == 'Edit' || $scope.action == 'Copy') {
$scope.action = "Update"
}
else {
$scope.action = "Save"
}
$scope.tinyArray = [];
$scope.screenshot = function () {
$scope.tinyArray.push($routeScope.tinyArray);
}
<div ng-repeat="elem in data">
<button id="{{elem.id}}" ng-click="showItem($index, elem)">
{{elem.name}}
</button>
</div>
Controller:
$scope.showItem = function(elementIndex, dataItem){
console.log(elementIndex); // 0
console.log(dataItem.id + ':' + dataItem.name); // 1:Abhishek
}

How to get data from two tables using Angular and displaying them in HTML?

I want to display two columns from two different tables.
I have table "offices" and "cash_desks"
Table "offices" have the column "name" which I want to display.
Table "cash_desks" have the columns "name" and "office_id"(which refers to offices id).
I want to display offices name and cash_desks name in HTML table.
Here is my HTML code:
<table class="table">
<tr ng-repeat="cash_desks in items" ng-click="editItem(cash_desks)">
<td>{{cash_desks.name}}</td>
<td>{{offices.name}}</td>
</tr>
</table>
<label><input type="checkbox" ng-model="myVar">Редактирай офис</label>
<div ng-show="myVar">
<div class="form">
<form ng-submit="saveItem(cash_desksForm.$valid)" name="cash_desksForm">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="offices_name">Код на валута</label>
<input type="text" class="form-control" required ng-model="activeItem.name" placeholder="Офис.." />
</div>
<div class="form-group">
<label for="value_name">Локация на офис</label>
<input type="text" class="form-control" id="password" ng-model="activeItem.location" />
</div>
</div>
</div>
<button class="btn btn-primary" ng-disabled="cash_desksForm.$invalid" type="submit">Save</button>
<!--<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Добавяне на нов</button>-->
</form>
</div>
</div>
And Angular Code:
app.controller("CashDesksCtrl", function($rootScope, $scope){
$scope.items = [];
$scope.editMode = false;
$scope.activeItem = false;
$scope.refresh = function () {
$scope.items = [];
window.defaultAdapter.query("SELECT offices.name,cash_desks.name FROM offices LEFT JOIN cash_desks ON offices.id = cash_desks.office_id LIMIT 8", { type: Sequelize.QueryTypes.SELECT})
.then(cash_desks => {
$scope.items = cash_desks;
$scope.$apply();
})
};
You have same key (name) from your select , try to use alias to make them differents.
<table class="table">
<tr ng-repeat="itemin items" ng-click="editItem(cash_desks)">
<td>{{item.cash_desk_name}}</td>
<td>{{item.office_name}}</td>
</tr>
</table>
<label><input type="checkbox" ng-model="myVar">Редактирай офис</label>
<div ng-show="myVar">
<div class="form">
<form ng-submit="saveItem(cash_desksForm.$valid)" name="cash_desksForm">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="offices_name">Код на валута</label>
<input type="text" class="form-control" required ng-model="activeItem.name" placeholder="Офис.." />
</div>
<div class="form-group">
<label for="value_name">Локация на офис</label>
<input type="text" class="form-control" id="password" ng-model="activeItem.location" />
</div>
</div>
</div>
<button class="btn btn-primary" ng-disabled="cash_desksForm.$invalid" type="submit">Save</button>
<!--<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Добавяне на нов</button>-->
</form>
</div>
</div>
app.controller("CashDesksCtrl", function($rootScope, $scope){
$scope.items = [];
$scope.editMode = false;
$scope.activeItem = false;
$scope.refresh = function () {
$scope.items = [];
window.defaultAdapter.query("SELECT offices.name as office_name,cash_desks.name as cash_desk_name FROM offices LEFT JOIN cash_desks ON offices.id = cash_desks.office_id LIMIT 8", { type: Sequelize.QueryTypes.SELECT})
.then(cash_desks => {
$scope.items = cash_desks;
$scope.$apply();
})
};

How to redirect to another ui-sref page in angularjs and show second page and first page hide?

when i redirect by using (ui-view) i face like this you can see image...
but i want to redirect to second page and login page should be hide using ui-view?
html code:here you can see
<div class="log-w3" ng-app="log" ng-controller="logcontroller">
<div class="w3layouts-main">
<h2>Sign In Now</h2>
<input type="text" ng-model="log.UserName" class="ggg" name="UserName" placeholder="E-MAIL" required="">
<input type="password" id="txtpassword" class="ggg" ng-model="log.Password" name="Password" placeholder="PASSWORD" required="">
<span><input type="checkbox" />Remember Me</span>
<h6>Forgot Password?</h6>
<div class="clearfix"></div>
<input type="submit" ng-click="login(log)" value="Sign In" name="login">
<img src="~/Design/images/loader.gif" id="loader" width="80" height="80" />
<div class="alert alert-success alert-dismissible" id="msg">
<strong>Success!</strong> Congraculation You Have Successfully Login!
</div>
<div class="alert alert-danger alert-dismissible" id="error">
×
<strong>Danger!</strong> Invalid Username or Password!
</div>
<p>Don't Have an Account ?Create an account</p>
</div>
<ui-view></ui-view>
</div>
angular js code:you can see the angular js code i use $state.go
.controller('logcontroller', function ($scope, Notification, $state, $http, cfpLoadingBar) {
$scope.login = function (log) {
$http.post("/Login/Info", log).then(function (response) {
cfpLoadingBar.start();
//console.log(JSON.stringify(response))
if (response.data.success) {
console.log('Login sucessfull');
Notification.success(response.data.message)
$state.go("/Log");
} else {
//alert(response.data.message)
Notification.error(response.data.message)
}
cfpLoadingBar.complete();
}, function () {
alert("Wrong ha")
})
}
})
.config(function ($stateProvider) {
$stateProvider
.state("/Log",
{
url: "Welcome",
templateUrl: "/Dash/Index"
})
});

How to show and hide <div>'s in Popover using AngularJS

I am working on SPA (Single Page Application) for Online Team Collaboration service(OTC) ,and I include HTML pages by ng-include,in some included page there is a popover ,this one contains a possibility for creating a public group chat,and in order to create one ,the user must submit, now my question is : how can i display a "successfully created" message in the same popover instead of the main div for creating the group in the popover?
The external page (the page that include other pages):
<div ng-show="ctrChanneldiv" ng-contoller="ctrChannelCon" style="float: right;" class="col-md-3">
<div ng-include="'CreateChannel.html'" ></div>
</div>
The Controller ctrChannelCon:
appvar.controller('ctrChannelCon',['$scope','$http','$rootScope',function($scope, $http, $rootScope){
$scope.createBtn = function() {
$http.post("http://localhost:8080/ExampleServletv3/crtchannelservlet",this.crtchannel)
.success(function(response) {
setTimeout(function () {
$scope.$apply(function(){
//******* Here Display "Successfully Created" In the Popover *******//
});
});
});
};
}]);
In CreateChannel.html :
<div>
<div class="row">
<a href="#" class="popper" data-toggle="popover"
data-placement="bottom"><span class="glyphicon glyphicon-plus"></span>Create Channel</a>
<div class="popper-content hide">
<div class="form-group">
<!-- ng-controller="createChannelCon" -->
<div class="form-group">
<label>Channel name:</label>
</div>
<div class="form-group">
<input ng-model="crtchannel.Name" type="text" placeholder="enter channel's name" maxlength="30"
class="form-control input-md" required />
</div>
<div class="form-group">
<label>Description:</label>
</div>
<div class="form-group">
<textarea cols="15" ng-model="crtchannel.Description" type="text"
placeholder="enter channel's description" maxlength="500"
class="form-control input-md" required></textarea>
</div>
<div>
<input ng-model="crtchannel.Type" type="radio" name="chtype"
value="private" required /> Private<br> <input
ng-model="crtchannel.Type" type="radio" name="chtype"
value="public" /> Public<br>
</div>
<div class="form-group">
<button ng-click="createBtn()" class="btn btn primary">Apply</button>
</div>
</div>
</div>
<script>
$('.popper').popover({
container : 'body',
html : true,
content : function() {
return $(this).next('.popper-content').html();
}
});
</script>
</div>
</div>
Any suggestions?
Thanks
You may use ngClass directive to counter this problem. ngClass directive allows conditional application of classes. Create a div for successfully created in the popup and set up ng-class directive with a variable in the scope and assign it true and false as per your requirement.
JS
appvar.controller('ctrChannelCon',['$scope','$http','$rootScope',function($scope, $http, $rootScope){
$scope.createBtn = function() {
$http.post("http://localhost:8080/ExampleServletv3/crtchannelservlet",this.crtchannel)
.success(function(response) {
setTimeout(function () {
$scope.$apply(function(){
//******* Change value of a model *******//
$scope.hidden = false;
});
});
});
};
}]);
HTML
<span ng-class="{hide: hidden}">Successfully Created</span>
CSS
.hide { display: none; }
Set a flag in your controller on success and use this flag to show or hide the success message:
...
<div class="form-group">
<button ng-click="createBtn()" class="btn btn primary">Apply</button>
</div>
<div ng-show="isSuccess">Successfully Created</div>
Inside the controller:
$scope.isSuccess = false;
$scope.createBtn = function() {
$http.post("http://localhost:8080/ExampleServletv3/crtchannelservlet",this.crtchannel)
.success(function(response) {
setTimeout(function () {
$scope.$apply(function(){
//******* Here Display "Successfully Created" In the Popover *******//
$scope.isSuccess = true;
});
});
});
};

Easy Responsive Tabs Plugin: Author: Samson.Onna need some modification

Please help me i implemented this js but I have problem when I call an event body click the tab content will also hide...
I used this code but problem is when i click on tab button its already hide..
$('body').click(function(e){
$('.resp-tabs-container').hide();
});
My HTML FILE
<div id="verticalTab">
<ul class="resp-tabs-list">
<li class="first flights"><em class="sprite"> </em>Book a Flight</li>
<li class="rooms"><em class="sprite"> </em>Book Hotel Rooms</li>
<li class="tickets"><em class="sprite"> </em>Book Movie Tickets</li>
<li class="vouchers"><em class="sprite"> </em>Book Vouchers</li>
<li class="new"><em class="sprite"> </em>What's New</li>
</ul>
<div class="resp-tabs-container">
<!--Book A Flight-->
<div>
<div class="tabForm">
<form action="">
<fieldset>
<div class="rowG select-opt flatui">
<p>
<input type="radio" name="tripOpt" checked="checked" />
<label>One Way</label>
<input type="radio" name="tripOpt" />
<label>Round Trip</label>
<input type="radio" name="tripOpt" />
<label>Multiple Destinations</label>
</p>
</div>
<div class="rowG clearfix">
<div class="col">
<label>Leaving From</label>
<input type="text" class="field" value="Location">
</div>
<div class="col">
<label>Departure Date</label>
<input type="text" class="field date-field" value="DD/MM/YY">
</div>
<div class="col selectdd">
<label>Time</label>
<select>
<option>Any</option>
</select>
</div>
</div>
<div class="rowG clearfix">
<div class="col">
<label>Going To</label>
<input type="text" class="field" value="Location">
</div>
</div>
<div class="rowG clearfix">
<div class="col selectdd">
<label>Adult (18-64)</label>
<select>
<option>1</option>
<option>2</option>
</select>
</div>
<div class="col selectdd">
<label>Seniors (65+)</label>
<select>
<option>1</option>
<option>2</option>
</select>
</div>
<div class="col selectdd">
<label>Children</label>
<select>
<option>1</option>
<option>2</option>
</select>
</div>
</div>
<div class="rowG clearfix"> <a data-toggle="collapse" data-target="#showAdditionalData" id="showAdditional" class="i-arrowup" href="#">Show Additional Options<span id="toggler" class="icon-chevron-left" ></span></a>
<div class="contents addpaddingT10">
<div id="showAdditionalData" class="collapse">
<div class="col">
<label>Preferred Airline</label>
<select>
<option>No Preference</option>
</select>
<p class="addpaddingT10">
<div class="flatui">
<input type="checkbox"/><label>Nonstop Flights Only</label>
</div>
</p>
</div>
<div class="col">
<label>Class</label>
<select>
<option>First Class</option>
</select>
<p class="addpaddingT10">
<div class="flatui">
<input type="checkbox"/><label>Refundable Flights Only</label>
</div>
</p>
</div>
</div>
</div>
</div>
<div class="rowG last clearfix">
<p class="floatL">
<div class="flatui">
<input type="checkbox"/><label>Redeem PR Points for this booking</label>
</div>
<input type="button" class="btn btn-primary search-icon floatR" value="Search">
</div>
</fieldset>
</form>
</div>
</div>
<!--End Flight book-->
<!--Hotel booking-->
<div>
<div class="tabFormHotel">
<form action="">
<fieldset>
<div class="rowG">
<label>Destination, hotel, landmark or address</label>
<input type="text" class="large" value="A city, airport or attraction">
</div>
<div class="rowG clearfix">
<div class="col">
<label>Check In</label>
<input type="text" class="field date-field" value="DD/MM/YYYY">
</div>
<div class="col">
<label>Check Out</label>
<input type="text" class="field date-field" value="DD/MM/YYYY">
</div>
<div class="col">
<label>Rooms</label>
<select class="selectpicker">
<option>Any</option>
</select>
</div>
</div>
<div class="rowG clearfix selectdd">
<legend>Room 1</legend>
<div class="c1">
<label>Adult <span>(12+ years)</span></label>
<select>
<option>1</option>
</select>
</div>
<div class="c1 selectdd">
<label>Child <span>(2-11 years)</label>
<select>
<option>3</option>
</select>
</div>
<div class="c2 selectdd">
<label>Child 1 Age</label>
<select>
<option>2</option>
</select>
</div>
<div class="c2 selectdd">
<label>Child 2 Age</label>
<select>
<option>6</option>
</select>
</div>
<div class="c2 selectdd">
<label>Child 3 Age</label>
<select>
<option>8</option>
</select>
</div>
</div>
<div class="rowG last clearfix">
<p class="floatL">
<input type="checkbox" />
<label>Redeem PR Points for this booking</label>
<br/>
<input type="button" class="btn btn-primary search-icon floatR" value="Search">
</p>
</div>
</fieldset>
</form>
</div>
</div>
<!--End Hotel-->
<div>
<p>Book Movie Tickets</p>
</div>
<div>
<p>Book Vouchers</p>
</div>
<div>
<p>What's New</p>
</div>
</div>
</div>
Here is the JS which i used
(function ($) {
$.fn.extend({
easyResponsiveTabs: function (options) {
//Set the default values, use comma to separate the settings, example:
var defaults = {
type: 'default', //default, vertical, accordion;
width: 'auto',
fit: true
}
//Variables
var options = $.extend(defaults, options);
var opt = options, jtype = opt.type, jfit = opt.fit, jwidth = opt.width, vtabs = 'vertical', accord = 'accordion';
//Main function
this.each(function () {
var $respTabs = $(this);
$respTabs.find('ul.resp-tabs-list li').addClass('resp-tab-item');
$respTabs.css({
'display': 'block',
'width': jwidth
});
$respTabs.find('.resp-tabs-container > div').addClass('resp-tab-content');
jtab_options();
//Properties Function
function jtab_options() {
if (jtype == vtabs) {
$respTabs.addClass('resp-vtabs');
}
if (jfit == true) {
$respTabs.css({ width: '100%', margin: '0px' });
}
if (jtype == accord) {
$respTabs.addClass('resp-easy-accordion');
$respTabs.find('.resp-tabs-list').css('display', 'none');
}
}
//Assigning the h2 markup to accordion title
var $tabItemh2;
$respTabs.find('.resp-tab-content').before("<h2 class='resp-accordion' role='tab'><span class='resp-arrow'></span></h2>");
var itemCount = 0;
$respTabs.find('.resp-accordion').each(function () {
$tabItemh2 = $(this);
var innertext = $respTabs.find('.resp-tab-item:eq(' + itemCount + ')').html();
$respTabs.find('.resp-accordion:eq(' + itemCount + ')').append(innertext);
$tabItemh2.attr('aria-controls', 'tab_item-' + (itemCount));
itemCount++;
});
//Assigning the 'aria-controls' to Tab items
var count = 0,
$tabContent;
$respTabs.find('.resp-tab-item').each(function () {
$tabItem = $(this);
$tabItem.attr('aria-controls', 'tab_item-' + (count));
$tabItem.attr('role', 'tab');
//First active tab
// $respTabs.find('.resp-tab-item').first().addClass('resp-tab-active');
//$respTabs.find('.resp-accordion').first().addClass('resp-tab-active');
//$respTabs.find('.resp-tab-content').first().addClass('resp-tab-content-active').attr('style', 'display:block');
//Assigning the 'aria-labelledby' attr to tab-content
var tabcount = 0;
$respTabs.find('.resp-tab-content').each(function () {
$tabContent = $(this);
$tabContent.attr('aria-labelledby', 'tab_item-' + (tabcount));
tabcount++;
});
count++;
});
//Tab Click action function
$respTabs.find("[role=tab]").each(function () {
var $currentTab = $(this);
$currentTab.click(function () {
var $tabAria = $currentTab.attr('aria-controls');
if ($currentTab.hasClass('resp-accordion') && $currentTab.hasClass('resp-tab-active')) {
$respTabs.find('.resp-tab-content-active').slideUp('', function () { $(this).addClass('resp-accordion-closed'); });
$respTabs.find('.resp-tab-active').removeClass('resp-tab-active');
return false;
}
if (!$currentTab.hasClass('resp-tab-active') && $currentTab.hasClass('resp-accordion')) {
$respTabs.find('.resp-tab-active').removeClass('resp-tab-active');
$respTabs.find('.resp-tab-content-active').slideUp().removeClass('resp-tab-content-active resp-accordion-closed');
$respTabs.find("[aria-controls=" + $tabAria + "]").addClass('resp-tab-active');
$respTabs.find('.resp-tab-content[aria-labelledby = ' + $tabAria + ']').slideDown().addClass('resp-tab-content-active');
} else {
$respTabs.find('.resp-tab-active').removeClass('resp-tab-active');
$respTabs.find('.resp-tab-content-active').removeAttr('style').removeClass('resp-tab-content-active').removeClass('resp-accordion-closed');
$respTabs.find("[aria-controls=" + $tabAria + "]").addClass('resp-tab-active');
$respTabs.find('.resp-tab-content[aria-labelledby = ' + $tabAria + ']').addClass('resp-tab-content-active').attr('style', 'display:block');
}
});
//Window resize function
$(window).resize(function () {
$respTabs.find('.resp-accordion-closed').removeAttr('style');
});
});
});
}
});
just use the follwing javascript to prevent the clicks
<script type="text/javascript">
$(document).ready(function() {
$("body").click(function(e){
if (!$(e.target).is('.ui-datepicker,.ui-datepicker *,.ui-icon,.ui-autocomplete,.ui-autocomplete *,.resp-tab-active, .resp-tab-active *, #verticalTab, #verticalTab *')) {
//$(".resp-tabs-container").hide();
$(".resp-vtabs li").removeClass('resp-tab-active');
$(".resp-vtabs .resp-tabs-container .resp-tab-content-active").removeClass('resp-tab-content-active').hide();
}});
});
</script>