can anyone tell what that is? I try to make middleware, and in addition to request request from input fields, but I get this error, I tried to find in Google nothing really could not find, images with error and middlewarre code I encloseenter image description here
enter image description here
As I can see, here I want to suggest that you should return a method(or route) in your first return sentence. Not just return a string like return "office". For example, if I have a function named:
public function activity() {
return 'It works.'
}
I will return return redirect('activity'); to replace your string sentences. Beacause I think your should return an object as it shows, so we at least return an object.
Related
Here is my code for factories.html
af.factory("PurchaseFactory",function(){
var productlist={products:[]};
return{
getpurchaseCart:function(){
return productlist;
},
addPurchaseCart:function(products){
productlist.products.push(products);
}
}
})
For Services.html
as.service("PurchaseService",function(PurchaseFactory){
this.getAllPurchase=function(){
return PurchaseFactory.getpurchaseCart();
}
this.addPurchase=function(products)
{
PurchaseFactory.addPurchaseCart(products);
}
})
For Controller.html
ac.controller("PurchaseController",function($scope,PurchaseService){
$scope.savepurchase=function(products){
if($scope.products._id==undefined){
$scope.products=angular.extend($scope.products,$scope.sizes)
PurchaseService.addPurchase($scope.products);
}
}
}
Here i have an another function in the same controller, as
$scope.saveorder=function(cartorder){
$scope.Mainpurchaselist=angular.extend($scope.cartorder,$scope.getpurchaseList)
CartService.addPurchaseCart($scope.Mainpurchaselist);
$scope.getpurchaseList.products={}
$scope.cartorder={}
$scope.products={}
$rootScope.isLogin=false;
CartService.deletecartyPurchase(idx);
Notification.success({message: 'your Cart Saving Successfully', delay: 1000});
}
In my HTML file, i have a button with function as savepurchase(products).
For first time its saving data but from second time its showing me error as TypeError:productlist.products.push is not a function. If I refresh the page its again saving the data, but continuously its not working.Let me know where the code goes wrong.
Here $scope.getpurchaselist.products={} is used to make a data null for every new purchase. If I remove the $scope.getpurchaselist.products={}, its working fine with no error but the problem is that the list is not getting null.
SO finally i have two ways
1. either to make it null by writing $scope.getpurchaselist.products={} but error as productlist.products.push is not a function let me know to overcome that error
2. Or to remove that line and let me know, how to make it null
I think, $scope.getpurchaseList.products={} is effecting you. As it passing an empty object instead of array as soon as the controller load. So, try removing it.
The condition if($scope.products._id==undefined) is breaking you. please check the logic you wrote. keep in mind $scope.products and products both are different variable in savepurchase function.
After extending $scope.products first time, condition return false.
change the $scope.products into just products. because u pass the products as paramater to the savepurchase() function. so no need to define as scope.products in ur controller
Something strange is happening. Actually I am assigning a title from asynchronous call and I'm applying a ucwords filter on the title. It is giving me the proper output but throwing the error first and after then showing the proper value.
HTML snippet:
<h1 ng-show="defaultProduct.Campaign.title">{{ defaultProduct.Campaign.title | ucwords }}</h1>
Filter Snippet
app.filter("ucwords", function () {
return function (input){
input = input.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
});
return input;
}
})
Please note defaultProduct.Campaign.title is assigning from AJAX call. It initializes after ajax success. In my console it is throwing the error first and after ajax success call it is showing proper output.
If input is show me first title then output will be Show Me First Title. But why it is throwing the error first ? I'm thinking to use $timeout in filter but it would not a good way of doing that. Can anyone suggest me best way ?
Below is the error :
Error: input is undefined
filters are evaluated on each digest cycle
Initially the value of defaultProduct.Campaign.title is not defined that is going to decide async call. At that time your custom filter is gets called before setting defaultProduct.Campaign.title value. Filter tries to input.toLowerCase() which return input is undefined where as input value is not defined. You should typically handle this scenarios inside your filter itself.
Filter
app.filter("ucwords", function () {
return function (input){
if(input) { //when input is defined the apply filter
input = input.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
});
}
return input;
}
})
I've two controllers one is "Upload" which deals with images uploads and other is "Page" whid deals with the creation of pages of CMS now if in my "Upload" controller I load both the models i.e 'image_m' which deals with image upload and "page_m" which deals with the pages creation I've highlighted the relevant code my problem is if I access the variables in the view
$this->data['images'] = $this->image_m->get(); sent by this I can access in foreach loop as "$images->image_title, $images->image_path" etc
But the variable sent by this line ***$this->data['get_with_images'] = $this->page_m->get_no_parents();*** as $get_with_images->page_name, $get_with_images->page_id etc produces given error
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: upload/index.php
Line Number: 20
what is the difference between these two access levels one for $image & other for $get_with_images because I can only access its values as $get_with_images
class Upload extends Admin_Controller {
public function __construct() {
parent::__construct();
***$this->load->model('image_m');
$this->load->model('page_m');***
}
public function index($id = NULL) {
//var_dump($this->data['images'] = $this->image_m->get_with_images());
//$this->data['images'] = $this->image_m->get_with_images();
***$this->data['images'] = $this->image_m->get();***
$this->data['subview'] = 'admin/upload/index';
if ($id) {
$this->data['image'] = $this->image_m->get($id);
count($this->data['image']) || $this->data['errors'][] = 'Page Could not be found';
}
$id == NULL || $this->data['image'] = $this->image_m->get($id);
/*this calls the page_m model function to load all the pages from pages table*/
***$this->data['get_with_images'] = $this->page_m->get_no_parents();***
You are not posting all your code so its hard to tell but is it because you used $this-> in the controller, but you haven't done the same thing in the view?
In this case i would recommend not using $this-> because its not necessary. Also its much better to check for errors etc when you call the model so do something like
if ( ! $data['images'] = $this->image_m->get($id) ) {
// Failure -- show an appropriate view for not getting any images
// am showing $data in case you have other values that are getting passed
$this->load->view( 'sadview', $data ); }
else {
// Success -- show a view to display images
$this->load->view( 'awesomeview', $data ); }
so we are saying if nothing came back - the ! is a negative - then show the failure view. Else $data['images'] came back, and it will be passed to the view. note i have not had to use $this-> for anything and it won't be needed in the view.
Would also suggest using separate methods - have one method to show all images and a separate method like returnimage($id) to show an image based on a specific validated $id.
====== Edit
You can access as many models as you want and pass that data to the View. You have a different issue - the problem is that you are waiting until the View to find out - and then it makes it more difficult to figure out what is wrong.
Look at this page and make sure you understand the differences between query results
http://ellislab.com/codeigniter/user-guide/database/results.html
When you have problems like this the first thing to do is make a simple view, and echo out directly from the model method that is giving you problems. Its probably something very simple but you are having to look through so much code that its difficult to discover.
The next thing is that for every method you write, you need to ask yourself 'what if it doesn't return anything?' and then deal with those conditions as part of your code. Always validate any input coming in to your methods (even links) and always have fallbacks for any method connecting to a database.
On your view do a var_dump($get_with_images) The error being given is that you are trying to use/access $get_with_images as an object but it is not an object.
or better yet on your controller do a
echo '<pre>';
var_dump($this->page_m->get_no_parents());
exit();
maybe your model is not returning anything or is returning something but the data is not an object , maybe an array of object that you still need to loop through in some cases.
I have this error:
Notice (8): Undefined variable: informations [APP/View/Information/index.ctp, line 2]
I have this function in my controller
public function index($slug){
$this->layout = 'sbhealth';
$this->loadModel('Menu');
$informations = $this->Menu->findBySlug($slug);
if($informations){
$this->set('index', $informations);
}else{
return $informations = "not find";
}
}
I need to pass datas to my view "index.ctp" index.ctp will then find the ID in my array to pass it to an Element. but the View doesn't recognize "$informations"
This probably doesn't constitute something that should be on StackOverflow, since it's specified in great detail in the book, but...
// in your controller
$this->set('informations', $informations);
The first item is the name of the variable that will be available in the view.
The second item is the value you want to put in that variable.
I got a qx.ui.form.Spinner object and I am setting the initial value from an XML file. The value is unfortunately returned as a string, which leads to the following confusing error in Firebug:
Error in property value of class qx.ui.form.Spinner in method setValue with incoming value '3': Is invalid!
Running this sample in the Playground doesn't produce any error, but the spinner is not being set:
// Create a button
var button1 = new qx.ui.form.Button("First Button", "icon/22/apps/internet-web-browser.png");
// Document is the application root
var doc = this.getRoot();
var spinner = new qx.ui.form.Spinner(1, 1, 60);
doc.add(spinner);
// Add button to document at fixed coordinates
doc.add(button1,
{
left : 100,
top : 50
});
// Add an event listener
button1.addListener("execute", function(e) {
spinner.setValue("3");
});
So my questions are:
should the string value be working? So far it seemed to be seldom a problem when number are actually string.
should the Playground give an error?
To answer your questions:
No, the string value will not work. Try using the parseInt() function to convert the string into an integer.
Actually the Playground is giving a problem, but the exception is not handled by the Playground, Try adding a try .. catch and you will see the exact same errormessage you already know.
try {
spinner.setValue("3");
} catch (e) {
alert(e);
}
Thanks.
I already uses parseInt() to get it worked and I submitted a bug report: http://bugzilla.qooxdoo.org/show_bug.cgi?id=4457
I daresay the Playground should at least log the error in its "Log" window. You might want to consider opening a bug for this.