Menu
  • HOME
  • TAGS

Targeting $index from ng-repeat

angularjs,controller,angularjs-scope

You would actually inject the object or index from your template. Something like this: <div ng-repeat="o in formData"> <button ng-click="getJob($index)">Click me!</button> </div> and then in your code: $scope.getJob = function(idx) { Employee.get({id: "" + $scope.formData[idx].ID}, function (data) { console.log(data); }) } Alternatively, instead of injecting the index, you could inject...

No Route Matches [POST] Bloc

ruby-on-rails,controller,routes

You should change resources :registered_applications to resources :applications in routes.rb, as Application is your model and applications is name of the table which is treated as resources. You are getting the error because there is no resource or table named registered_applications, as you have named your table as applications and...

How to call this function for every controller in codeigniter

php,codeigniter,controller,autoloader

You can create a library for this purpose and autoload this library. Creating a library is explained in the given link codeigniter library Or you can refer to a somewhat same question asked in the stackoverflow Stack overflow post...

Activeadmin where to place this variable code from my view

variables,ruby-on-rails-4,controller,activeadmin

Putting the code into AA controller block is right idea. controller do def index supply_company_id = SupplyCompany.find(params[:id]).id # note .id part - it makes sure you pass an id not the whole object in the query below @ccarray = CompanyScore.where(supply_company_id: supply_company_id).pluck(:score) end end ...

Using the controller to manage render logic rather than view

html,ruby-on-rails,controller

Helper method is the answer.. Move it in some method in your helper like def my_awesome_helper_method - logic - end and in the view just call <%=my_awesome_helper_method %> much cleaner...! ...

Where is the syntax error in my rails app?

ruby-on-rails,controller

You are missing end of the if clause. Right code is def tx if params[:type] == "transaction" && params[:hash].present? AMQPQueue.enqueue(:deposit_coin, txid: params[:hash], channel_key: "satoshi") render :json => { :status => "queued" } end end ...

Accessing child functions/properties with arranged content in Ember.js

javascript,ember.js,controller

I would move the imageUrl property to the model: App.Post = DS.Model.extend({ ... imageName: DS.attr('string'), imageUrl: Ember.computed('id', 'imageName', function() { var id = this.get('id'); var postImageRoot = "images/posts/" + id + "/"; var imageName = this.get('imageName'); return postImageRoot + imageName; }) }); http://emberjs.jsbin.com/nohazilegi/1/...

Laravel 5 form submit creates an error MethodNotAllowedHttpException

php,forms,controller,routes,laravel-5

Can you change this: Route::post('profile/edit', array( 'as' => 'admin.profile.update', 'uses' => '[email protected]' )); To this: Route::patch('profile/edit', array( 'as' => 'admin.profile.update', 'uses' => '[email protected]' )); I think your form action may need a matching route verb http://laravel.com/docs/5.1/routing#basic-routing For the second issue: Column not found: 1054 Unknown column '_method' in 'field list'...

Rspec test public controller method passing params to private controller method

ruby-on-rails,ruby-on-rails-4,rspec,controller,rspec-rails

Stubbed methods return nil by default. Use and_return to specify the value returned by the stub:: StripeService.should_receive(:new).and_return(whatever) or using the newer syntax expect(StripeService).to receive(:new).and_return(whatever) EDIT Pardon my hand-waving. Your stub must return an object that will act like an instance of StripeService to the extent required for the purposes of...

Pass an id and get it from actionLink to view page

asp.net-mvc,view,controller,html.actionlink

If your view's name is Catalog, you need to change your ActionLink to point to the corresponding action: @Html.ActionLink("Formations", "Catalog", "Formation", new { id = item.Id }, null) action: public ActionResult Catalog(int id) { var formations = db.Formations.Where(f => f.idC == id).ToList; return View(formations); } view: @model IEnumerable<ProjectName.Models.Formation> // loop...

Using controller inside another controller in AngularJS

angularjs,binding,controller

As you are using controllerAs you should be using this keyword in controller angularApp.controller('InsideCtrl', ['$scope', function ($scope) { var vm = this; vm.states2 = ["NY", "CA", "WA"]; }]); Forked Fiddle NOTE Technically you should follow one approach at a time. Don't mix up this two pattern together, Either use controllerAs...

Opencart module controller index function data source

model-view-controller,controller,opencart

The $this->config->get object is set initially from index.php file as a current setting and not as a module tracking. The $setting array passed into the index method is the one initialized whenever the current module is loaded at that point in the loop. The $setting object should be initialized automatically...

Return Error and view in ajax

jquery,ajax,asp.net-mvc,controller

Return the error code as a HttpStatusCodeResult, if you just send a reply there is no way of Ajax knowing it is an error unless you check for specific text in the response. public ActionResult Test() { string ErrorText = string.Empty; if(true) return View("PagedList"); } else { return new HttpStatusCodeResult(500,...

Ionic update Checkbox value

angularjs,controller,ionic-framework,alert,ionic

The problem is in the scope. I answered a question few days ago where I have some links to some tutorials where they tell you exactly why you should avoid using scope as a model. The best solution is to avoid $scope to attach your view model. You can have...

How to make a variable set in controller, available in other class?

ruby-on-rails,ruby,ruby-on-rails-4,controller

You can pass down the variable when creating the UsersGrid instance, then save it in an instance variable there. In controller: def index @show_column = (current_user && current_users.admin?) @grid = UsersGrid.new(params[:users_grid], @show_column) do |scope| scope.where(admin: false).page(params[:page]).per_page(30) end @grid.assets end In the grid class: class UsersGrid def initialize(*params, show_column) super *params...

Signout from a controller in rails 4

ruby-on-rails,devise,controller

You are redirecting, which makes a GET request to devise#sessions#destroy, a route that doesn't exist. The signout route in Devise is a mapped to a DELETE request. Instead of redirecting you should directly call the sign_out method that Devise makes available to you. After that be sure to redirect the...

MVC inquiry, controller checks condition, stay on current page

asp.net-mvc,controller

From a controller method you can return either a View, a File, a PartialView, a Json or even more. If you want the page stay there without refreshing, my suggestion is to use Ajax to submit your request and then return a Json. In the view: <script type="text/javascript"> function doSomething()...

Cakephp3 redirect in beforeFilter is not working

redirect,controller,cakephp-3.0,before-filter

Since I was returning the response object only from the beforeFilter in the AppController the redirect did not work. For further details check out https://github.com/cakephp/cakephp/issues/6705.

Controller issue: undefined local variable

ruby-on-rails,ruby,ruby-on-rails-4,controller

It should be like this: if @organization.update_attributes(subscription: true, actioncode: session[:actioncode_id], subs_exp_date: check_expiration_date(@organization)) If you see your code, expiration_date is a variable inside method check_expiration_date which limits its scope only to that method. Hence you cannot use variable expiration_date outside check_expiration_date. Other way can be defining expiration date as an instance...

calling the parent controller function in Ext.Ajax.request

extjs,view,controller,scope

Scope issue. When you call this in the success callback, you're not at the same scope where the startMain function is defined. One solution is to declare a reference to the correct scope right inside the doLoginClicked function: doLoginClicked : function () { var me = this; console.log("button pressed this...

More than one controller in one Bundle (Symfony)

php,symfony2,controller

So you will have controlelrs at src/MyApp/SomeBundle/Controller/ class OneController extends Controller { public function indexAction() { .... } } class TwoController extends Controller { public function addclientAction() { .... } } you routing.yml should looks like my_route_index: pattern: / defaults: { _controller: MyAppSomeBundle:One:index } my_route_addclient: pattern: /addclient/ defaults: { _controller:...

How can i access scope in angular service

javascript,angularjs,controller

Use the service(s) itself to share the variable as part of the service object as well as methods of each service .service('Service2', function($q) { var self = this; this.var1 = 'test1'; this.save = function(obj) { } }); app.controller('TestCtrl2', ['$scope','Service1','Service2', function ($scope, Service1, Service2, ) { // bind scope variable to...

Displaying a table's row in a div element using AngularJS

javascript,angularjs,service,view,controller

You can just set the row response to controller scope and then access it in the view. In the view you can use angularJS ng-repeat directive to loop through all the records from table response and render the required data. Js myService.PHP.getTableRows(function(getTableRowsResponse){ // getTableRowsResponse contains all of my rows in...

JAVAFX LISTVIEW REFRESH TAB

listview,javafx,controller,reload

The problem is each of your ListViews contains a different ObservableList with the data. So removing from one list will not remove from the other. The best solution is to let both list views share a single data list. Have your ModelFactory class create a (single) ObservableList<Model> and return it...

Is bootstrap file a controller?

php,oop,model-view-controller,controller

No, bootstrap file is for initialization. A controller is resoponsible for handling user input (requests in a web environment) and providing him an output (responses in a web environment). A front controller is just a centralized point for handling incomming requests. None of these compoments should have the responsibility of...

Rails extended “show” function

ruby-on-rails,ruby-on-rails-4,model-view-controller,controller,routes

There is not much things to do to achieve that. It's pretty easy. From what I understand you need url like "/entities/12/custom_view" and you want to find entity with id 12 and render the that entity info in custom_view template. Her's how to achieve that: Add a route for new...

Switching an app from displaying one quote at random to all in a grid

ruby-on-rails,controller

In your controller def index @quotes = Quote.order("RANDOM()") end Then in your view [email protected] do That should do the trick...

Grails: Carry forward params on hyperlink is clicked

grails,redirect,controller

If you look to the redirected URL, you will realize that params are carry forwarded correctly. 11 the only params you have in your delete action and that is forwarded to list action (.../list/11) after successful delete. The issue is that you are not passing max and offset with delete...

How to delete functions of previous instances of controller?

javascript,angularjs,controller,state,reload

Events are not cleared from DOM automatically though they are attached from controller. You could do that by ensuring the event bind only once. you could unbind it first & then bind it again. Code $document.unbind('click');//ensure it will bind once $document.bind('click', function(e) { testing(); }); And for more specifically you...

Click actionlink on view, controller checks condition, returns JSON, jQuery Ajax doesn't work

ajax,json,controller,asp.net-mvc-5,actionlink

Your question is anything but easy to interpret, but as for "Ajax doesn't work": You state that "the @Html and <script> are together in a loop which goes through all the customers". This will be the first error, since this would create a lot of elements using the same Id,...

How to make satellizer use absolute url's?

angularjs,controller,forms-authentication,oauth-provider,satellizer

Set in your config: $authProvider.baseUrl = null; ...

redirect to action of different controller not retaining variable

c#,asp.net-mvc,controller,actionmethod

You cannot pass a complex object via the query string like that using the built in utilities. You should send a reference to that object (something like an ID) where you can re-look it up on the other end. This only works if the Person is stored somewhere though (session,...

How Do I call and pass data to a Directive from a Controller Angular

angularjs,laravel,angularjs-directive,controller

It looks like it's going to be something reused so I'd strongly suggest to use service/factory I've made few examples for you of the way to pass data to directive app.service('postService', function postService($http) { var postDataMethod = function (formData) { $http.post('http://edeen.pl/stdin.php', formData) .success( function (data) { service.response = data })...

AngularJS: Making a from invalid based upon contents of an input

angularjs,controller,html-form

It is quite simple. For the ng-disabled along with your form invalid property, you can also check $scope.validPassword as bellow. Here is the edited code: <div class="modal-footer"> <button type="submit" ng-click="save()" ng-if="user.Id" ng-disabled="userForm.$invalid || !$scope.validPassword" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> Save User</button> <button type="submit" ng-click="add()" ng-if="!user.Id" ng-disabled="userForm.$invalid || !$scope.validPassword"...

Using the same DbContext object across different controllers

c#,controller,asp.net-mvc-5,entity-framework-6,dbcontext

You should not have the same dbContext for all controllers. It is not a good practice to do so because that way the framework has to track a lot more entities and if something goes wrong on EF side, it will be difficult to debug too. Use one dbContext per...

Call rendering from another controller

ruby-on-rails,ruby,controller,render

You need to explicitly build the output that you need in the all controller action, rather than trying to join the outputs of other actions. Two approaches: Retrieve the items you want with two database calls, join them together into one big set of list items, then render the list...

JavaFX : Button never sets a graphic

java,javafx,controller

You're blocking the UI thread with Thread.sleep(...). That prevents any pending changes from being repainted, so you don't see the first update at all; you only see the subsequent updates after the pause is complete. The simplest way to implement a pause on the UI thread is to use a...

Angularjs $http.get service not returning data to calling controller function

angularjs,service,controller

$http service is aync in nature so you need to assign data in a callback GetDataService.getData('/getBroadcastSourceList/1').then(function(data) { $scope.items=data; }) Also your service does not have a return, add it. this.getData = function(ServiceParameter) { return $http.get(WebServiceURL + ServiceParameter) ...

rspec controller empty session

ruby-on-rails-3,testing,rspec,controller

Try: expect(session['dr']).to eq("dr"). session values are separate from assigns....

php function to check when an uploaded image has been in the directory for longer than a day

php,file-upload,controller,cron,unlink

Looks like you have inconsistent directory names. Try this: public function delete_gallery_images() { $dirName = '../public/images/gallery_images/files/'; $dir = opendir($dirName); if ($dir) { // Read directory contents while (false !== ($file = readdir($dir))) { if($file != "." && $file != "..") { // Check the create time of each file (older...

insert variable value to database from another function in codeigniter?

php,codeigniter,controller

In your controller function save_abc(){ $ArrData = array( 'database_column'=>'value', 'database_column2'=>'value2', ); $this->your_model->your_function($ArrData); } In your model public function your_function($data=''){ $this->db->insert('your_table',$data); } Update solution You can do one thing In your view file save $date values in hidden field and create a button save data that call action save_abc() now you...

How to get the value from model to controller

php,codeigniter,model,controller

CI is a MVC Framework. So you need to Command from Controller and get data from the models and finely you need to pass them to view. This is a best Practice Controller function checking() { $email=$this->input->post('email'); $this->load->model('login_model'); $data['dbemail']=$this->login_model->email();// assign your value to CI variable $this->load->view('home', $data); //passing your value...

Make a required field if the other field has value

javascript,c#,jquery,controller,asp.net-mvc-5.2

Implementing IValidatableObject on your view model allows for greater control over ad-hoc validation rules like this. Example public class Department : IValidatableObject { public int? BossId { get; set; } public DateTime? HeadShipDate { get; set; } ... public IEnumerable<ValidationResult> Validate( ValidationContext validationContext ) { if( BossId.HasValue && !HeadShipDate.HasValue )...

Rails - Create and update two models in one controller - SOLVED

ruby-on-rails,model,controller

Instead of @order.listing.passengers = params[:passengers], try @order.listing.update_attribute(:passengers, params[:passengers]).

Assign one of values in controller

ruby-on-rails,controller

You can do what @OscillatingMonkey suggested, but I would strongly suggest to use a hidden field tag in your new form: <%= f.hidden_field :category_id, value: @post.category_id %> In that case your controller new would be: @post = Post.new(category_id: 1) Calling save in new action is a terrible thing, AFAIK. Every...

The best (or the proper) way to reuse action at any route? [Laravel 4.2]

php,laravel,view,laravel-4,controller

You are using V4.2 , which has something called View Composer Check out this tutorial. This will solve your problem I think....

RSpec 3 - Test controller action that does not have routes

ruby-on-rails,ruby-on-rails-4,rspec,controller,rspec3

action_b should really be a private method. Normally, you would not test this directly, you would verify it implicitly by testing action_a.

rails controller test failing non-deterministicly wrt state leak (I think)

ruby-on-rails,testing,controller,strong-parameters

Turns out I needed to call @subscription.reload.

Open in same view controller as closed on (swift)

swift,view,controller,save,nsuserdefaults

You can use NSUserDefaults which will remember your last ViewController. first of all you have to store some integer when you load any view like shown below: FirstView.swift override func viewDidLoad() { super.viewDidLoad() NSUserDefaults.standardUserDefaults().setInteger(0, forKey: "View") // Do any additional setup after loading the view, typically from a nib. }...

Cannot implicity List into IEnumerable

c#,asp.net-mvc,controller,viewmodel

As the error implies, System.Web.WebPages.Html.SelectListItem and System.Web.Mvc.SelectListItem are not the same thing. ViewModelCT and your controller are referencing different SelectListItem classes. Check your using statements in each file. I suspect one has using System.Web.Mvc and the other has using System.Web.WebPages.Html....

Sort a LINQ with another LINQ in MVC

sql-server,linq,entity-framework,controller

Try this: var materialnumb = (from r in db.MaterialNumber where r.MaterialNumber == 80254842 select r.MaterialNumber).FirstOrDefault(); var query = from r in db.SQLViewFinalTable where r.MaterialNumber == materialnumb select r But I can not get whay are you filtering by 80254842 and selecting the same value? You can do directly: var query...

How to add .php extension to Codeigniter 2.x controller URL's

php,.htaccess,codeigniter,url,controller

Took me like 10 seconds to find this on Google: http://www.codeigniter.com/userguide2/general/urls.html Adding a URL Suffix...

Resolve promise in service without callback in controller

angularjs,callback,controller,promise,angular-promise

My best practice with regards to services requesting data and returning promises is: return a promise (in DataService, return deferred.promise) in the controller, call DataService.getData(3).then(, ) So I would not pass a callback to a service function that uses a promise. The more difficult question is what should the service...

zend2 adding another controller to application

controller,routing,zend-framework2

You can have multiple controllers in a single module, but you need to set up your routing to identify when to use which controller. Since you have referenced Akrabat's album module in your question, I'll use it to illustrate: The album module tutorial shows how to create four actions: indexAction,...

Rails 4 routing issue, or something else; I am not sure at this point

ruby-on-rails,ruby-on-rails-4,controller,routes

You should try and reproduce this on a development environment so you can see the stacktrace, telling you exactly what went wrong rather than just getting a server error. In your controller action you're doing this: year = ((params[:dyear]).gsub(/\D/,'') But there's an unclosed parenthesis, so you're most likely getting a...

ParameterMissing param is missing or the value is empty

ruby-on-rails,ruby-on-rails-4,view,controller,parameter-passing

Change your view to drop the :as option, that will fix the params requirement error: = form_for @user, :url => admins_update_path(id: @user) do |f| The :as tells form_for to use a different key name than the default class-name based one that you're using in your params.require call. You should also...

Reading from database in Laravel 4

laravel,model-view-controller,controller,blade

Very vague question, so will be the answer. Please clarify if it's not what you need. Assumptions: You have an Item model that is stored in a DB. In the relevant controller method you add the code below which will find the item with id 1 and will display the...

AngularJS directive: scope with named controller

angularjs,controller,directive

You never was binding the scope variables to the named controller in the directive. You must add the attribute bindToController: true to the directive definition like this plunker: http://plnkr.co/edit/2QdnkpeuTM6adG9KoyJT?p=preview Directive code: app.directive('outputContent', function() { return { restrict: 'E', replace: true, templateUrl: 'outputContent.html', scope: { data: '=', changeLabel: '&', result: '='...

Passing params to an angular service from a controller?

javascript,angularjs,service,controller,params

You can declare your service as: app.factory('books', ['$http', function($http) { // var url = 'http://...' + ParamFromController + '.json' return { getVal: function(url,options){ return $http.get(url,options) } } }]); and use it in your controller and provide appropriate params to pass into 'books' service: app.controller('BookController', ['$scope', '$routeParams', 'books', function($scope, $routeParams, books)...

Angular is giving me an injection unresolved error, but my controller isn't asking for any injections

javascript,angularjs,controller,modal-dialog,inject

So this is super embarassing. Basically when I copied and pasted the modal controller out of the previous place where I had it, I forgot to delete the old (string named) controller. Angular was randomly choosing between the two identically named modal controllers when opening the modal, and giving me...

Override one attribute in Rails strong params

ruby-on-rails,ruby,controller

If all you want to do is override the name to some other string, or format it before saving, you can just do: @person = Person.new(person_params.merge!(name: 'ABC')) If you want to do the create and merge in one line, simply do this: def create @person = Person.create(person_params.merge!(name: 'ABC')) end ...

JQuery AJAX Success With Multiple MVC Controller Methods

jquery,ajax,asp.net-mvc,controller

RedirectToAction returns a HTTP status code of 302, which makes AJAX do a GET to the redirect URL (SecondMethod). jQuery AJAX success only gets called when a 2XX HTTP code is returned. If SecondMethod returns something with a 2XX status code (such as a View), it will be then. Otherwise,...

AngularJs: programmatically filter by either of 2 columns

javascript,angularjs,controller,filtering

Update Deleted irrelevant/mistaken initial answer Since you're applying $filter inside a JS script, and it doesn't use any of the advanced features of $filter, I'd switch over to the JS-native method of filtering an array: $scope.filteredTransactions = $scope.invoiceTransactionsObject.transactions.concat(); // make a copy of the initial array if ($scope.searchTerm.message) { var...

file_get_contents() expects parameter 1 to be a valid path

image,codeigniter,model-view-controller,controller,file-get-contents

$data contain array values, you have to use upload_data for ex : $data = array('upload_data' => $this->upload->data()); $data = array( 'image' => file_get_contents( $data ) ); change this to $data = array('upload_data' => $this->upload->data()); $data = array( 'image' => file_get_contents( $data['upload_data'] ) ); or you can directly use upload data...

How can I pass data between GSP and controller in Grails without storing in the database?

grails,controller,gsp

None of the data passed from a view to a controller has to line up with any particular Domain. There are a couple of ways you could do this. the view: <g:textField name="name" /> the controller: class SomeController { def someAction() { def name = params.name // do something with...

Controller method: Contact form should render different page depending on where the form is used

ruby-on-rails,ruby,forms,ruby-on-rails-4,controller

You can use something called action_name in Rails 4. action_name gives you the name of the action your view got fired from. Now you can send this property to the method create through a hidden field like following: <%= hidden_field_tag "action_name", action_name %> This line of code will send params[:action_name]...

AngularJS - controller doesn't get data from service when using $http

angularjs,http,service,controller,is-empty

You have to learn about promises: http://chariotsolutions.com/blog/post/angularjs-corner-using-promises-q-handle-asynchronous-calls/ In the service you should return directly the promise of the call to the $http-Service: this.getTrips = function() { return $http.get('trips.json').then(function (response) { trips = response.data; return trips; }); }; In the controller you have then to call the then-method to access the...

Pass parameter from controller to service in Angular

angularjs,service,controller

You would need to inject City Service, When using explicit dependency annotation, it is all or none rule, you cannot just specify part of your dependencies. angular.module('CityCtrl', []).controller('CityController', ['$scope', '$http', 'City' function($scope, $http, City){ Also you cannot inject $scope in a factory (It is available for injection only to controllers,...

Rails category (or filter) links in same controller?

ruby-on-rails,ruby,hyperlink,model,controller

belongs_to is defined in ActiveRecord::Associations, which is part of ActiveRecord. You are manually including ActiveModel::Model which doesn't offer any association-related capabilities. Includes the required interface for an object to interact with ActionPack, using different ActiveModel modules. It includes model name introspections, conversions, translations and validations. Besides that, it allows you...

View from custom controller overriding default view

model-view-controller,controller,routes,orchardcms

Your route overrides all routes ({*path}. So when you redirect, you redirect to....your redirector I guess. Therefore the view you are rendering is the one for your controller, not the page you were after. Whatever the logic flaw - this is not a good way to globally control authorization type...

Laravel Authentification fails

authentication,laravel,login,controller

Taken from the Laravel Authentication Documentation: Remember: when building the database schema for this model, make the password column at least 60 characters. Also, before getting started, make sure that your users (or equivalent) table contains a nullable, string remember_token column of 100 characters. For future reference, Laravel ships with...

Configuring inputs for a Multiple Input Fuzzy Controller in Labview?

input,controller,logic,labview,fuzzy

I have two nodes which give double values, which I then put into an array using the Build Array VI I assume you mean that they give 1D DBL arrays, because you can't get from scalars to a 2D array. Most likely you need to right click the BA...

Checkboxes array of bools doesnt brings the true value if it's checked by user

asp.net-mvc,controller,asp.net-mvc-5,views

Remove the hidden input your creating for the same property @Html.HiddenFor(m => m.array[i]) The DefaultModelBinder reads the first name/value pair match your property name and binds it. Any subsequent name/value pairs are ignored so the value of the inputs created by @Html.CheckBoxFor(m => m.array[i]) are ignored. You also need to...

AngularJS Passing changing values from Controller to a Directive Controller

javascript,angularjs,controller,directive

You are close: Your markup should look something like: <div ng-controller="testCtrl"> <test-dir result-data="results"></test-dir> </div> app.controller('testCtrl', function($scope){ $scope.getData = function(){ //getDataFunc is a method in a Factory, which is not shown here $scope.results = getDataFunc(); } } app.directive('testDir', function(){ return{ restrict: 'AE', scope: { resultData: '=' }, controller:['$scope', function($scope){ //I need...

AngularJS factory inside ng-class on body tag not working

angularjs,controller,factory,angular-services,ng-class

The $scope of the controller you're attaching the value to doesn't extend to the <body> element. Instead, you can whip together a directive: .directive('shouldScroll', function (Scroll) { return { restrict: 'A', link: function ($scope, elem) { $scope.$watch(Scroll.isScrollingEnabled, function (n) { if (n) { elem.addClass('scrolling'); } else if (n === false)...

Rails form: A field showing the value of one variable but saving it to another variable

ruby-on-rails,ruby,forms,ruby-on-rails-4,controller

You can supply a default value to an input field: <%= f.email_field :new_email, value: @user.email, class: 'form-control' %>...

Move some code from controller to factory in angular

angularjs,controller,factory

That's right you don't need $scope in your factory. Factory should be just a toolbox for your controller. Here is a example based on your code. //factory .factory("uploadFactory", function ($http) { return { // upload: $resource("/api/EasyPay/") upload: function (data) { $http({ method: 'POST', url: "/api/Upload", headers: { 'Content-Type': undefined },...

Computed Property not working

ember.js,controller,ember-data,computed-properties

You should be watching for changes on [email protected], todos is not a property of your controller (it's just a local variable inside your computed property).

Silex can't find Controller Class

php,controller,silex

Sigh, it was a capitalization issue. My macbook has a case insensitive filesystem and my linux VPS has a case sensitive filesystem so when deploying to Linux I had to capitalize the directories in my project so that Silex could correctly resolve the controllers.

Can not reach to associated models from Jquery

javascript,jquery,ruby-on-rails,controller,models

You are most likely trying to use javascript variable in ruby. This kind of confusion is one many reasons to avoid intermingling your client side and server side code. Instead you can use data attributes and ajax to pass data to javascript. <div id="map-canvas" data-initlat="<%= @initlat %>"></div> Or another example:...

USB3 Controller & Kinect 2

controller,usb,driver,kinect,fresco

Not all the USB 3 controllers support Kinect v2. As described in this page from Xbox.com: Only USB3 controllers from Intel and Renesas are supported If you use a different brand of USB3 controller, the Kinect sensor may not function correctly. In this other page (from the official documentation on...

controller logic for two different type of users

ruby-on-rails,ruby-on-rails-3,ruby-on-rails-4,model-view-controller,controller

There's no single right answer to this question, it really depends a lot on your code, your app, your use cases, and a whole bunch of other detail that you haven't provided (and that this is not the best forum for). So, generally the administration tasks are so distinct from...

How to get variables from another controller

c#,asp.net-mvc,asp.net-mvc-4,controller

It seems like the only difference between each of the stopped counts is the LocationID. In this case you could just make a single method to handle them all: public int GetStoppedCount(int locationId) { return db.Jobs.Where(x => x.Status == "Stopped" && x.LocationID == locationId).Count(); } You could then do: ViewBag.HBAStopped...

Upload picture NO plugin NO activerecord

ruby-on-rails,ruby-on-rails-4,upload,controller

Since you're using form_for, the actual temp file will be in params[:product][:upload]. Try this Within the _form.html.erb partial, change the file_field line to <%= file_field :upload %> Then, within your create action name = params[:product][:upload].original_filename directory = Rails.root.join('app', 'assets','images') # create the file path path = File.join(directory, name) # write...

Controller method #show getting called

ruby-on-rails,ruby,controller

There is a footnote in the canonical Rails Routing from the Outside In to the effect: Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action's route for the resources line will be matched before the...

computed property that changes its value with action in Ember.js

javascript,ember.js,controller

You could define property selectedElement (that's clicked). When loadRight fired you could set selectedElement with selection. Then currentElement is simple computed property, depends on model.firstObject and selectedElement. export default Ember.Controller.extend({ firstElement: function () { return this.get('model.firstObject'); }.property('model.[]'), selectedElement: null, currentElement: function () { return (this.get('selectedElement') || this.get(`firstElement`)); }.property('firstElement', 'selectedElement'), actions:...

JSON response from SpringMVC controller is not working

java,json,spring-mvc,controller

Given @ResponseBody with a POJO type return type, a default MVC configuration with @EnableWebMvc or <mvc:annotation-driven />, and Jackson on the classpath, Spring will try to serialize the POJO to JSON and write it to the response body. Since it's writing JSON, it's going to attempt to write application/json as...

MVC controller returns JSON. But to where?

json,asp.net-mvc,controller

If an Action Method returns Json, the View doesn't get involved. In all cases, an action method of a controller returns something to response stream. Notice the return statement below. Actually it's calling the view first. Think of it like a method call. And then whatever the view is, is...

How can I stub a controller instance variable using RSpec?

ruby-on-rails-3,rspec,controller

In fact the instance variable is set to the value that you provide in the example, but that happens before the before_filter executes, so it ends up being set again. You could move the initialization from the before_filter into a method in the controller and stub that instead: before_filter {...

Why do I keep getting 'undefined method' when it's worked fine before?

ruby-on-rails,ruby,ruby-on-rails-4,controller

Check Fields of the Order Model. Do you have listing_id as a column on the orders table ? Check the migration files to make sure that somewhere along the way you have added a "listing_id" field to the "orders" table.

How to get temperature value from DS18B20 voltage

controller,arduino,hardware,sensor,temperature

You need to connect the 18B20 to a microcontroller, or a 1-wire host controller, connected to the microcontroller. (The difference is whether you want to write your own 1-wire protocol code ... go with the host controller). You'll get a digital value for the temp, no ADC required.

How to access properties inside an array and push them to a List Angularjs

json,angularjs,http,controller

have a look at this code on button click save function will be called and value will be stored in reports array. <doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head> <body ng-app="myApp" data-ng-controller="HomeCtrl"> <button ng-click="save()">Save</button> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> <script> var app =...

refactoring Rails 4 before_action for code speed with reused controller methods

ruby-on-rails,ruby-on-rails-4,controller,refactoring

You asked two different questions here. A good way to abstract methods so they are resuable would be in the form of a Module or a superclass which your subclass inherits behavior from. Think of a rails model inheriting ActiveRecord::Base and how it inherits database access methods etc. You are...