controller

What is the advantage of using multiple Controller classes in ASP.NET MVC?

半世苍凉 提交于 2019-12-08 08:34:58
问题 I'm just learning the basics of ASP.NET MVC and am wondering what the benefit is in breaking up website logic amongst multiple controllers versus just having a single Controller class that runs the whole website, besides simply organizing code better. (In my opinion, just the latter benefit should not be enough to affect the end user via the url due to separation of concerns: the implementation details of the site should not be being reflected in the urls the site uses, no?) Some examples on

MVC: Variables used for only for user-registration. Placed in Controller helper or Model?

谁说胖子不能爱 提交于 2019-12-08 08:04:34
问题 I found myself in a grey area while cleaning up my "Registration" method in my MVC. Quick background: I create arrays of values that are associated for a particular task. For example: $field_arr //array of all the values from the register-form. $user_arr //array of values needed to create a new user. $required_arr //array of all values that are required for sign up. $values_arr //array that holds all the values for the items in the multiple arrays. etc...etc... At first I began just

AngularJS notifying view of changes to model

為{幸葍}努か 提交于 2019-12-08 07:50:28
I'm trying to display the current time in a view based on a Javascript Date object in my controller. My controller looks like this: myApp.controller('DateCtrl', function($scope) { var date = new Date(); $scope.minutes = date.getMinutes(); $scope.hours = date.getHours(); $scope.seconds = date.getSeconds(); var updateTime = function() { var date2 = new Date(); $scope.minutes = date2.getMinutes(); $scope.hours = date2.getHours(); $scope.seconds = date2.getSeconds(); } $scope.clickUpdate = function() { setInterval(updateTime, 1000); } }); In my view I simply have: <div ng-controller="DateCtrl">

MVC3 using routes or using controller logic?

流过昼夜 提交于 2019-12-08 07:37:51
问题 I'm relatively new with MVC3, but I'm using it, C# and EF4 to create an application website. The routing that I'm using is the same as in the default Microsoft project created when I selected MVC3 pattern, nothing special: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter

TypeError: $scope is undefined in Angular controller unit test with Jasmine

一个人想着一个人 提交于 2019-12-08 06:53:10
问题 This is a very simple, quite pared down test and controller. My controller 'LedgerCtl' has an injected service 'LedgerService' that I test elsewhere, so in my LedgerControllerSpec I created a function that stands-in for the mocked service. When I execute the test, I get the 'scope undefined' error. this and this are the closest answers I found; however neither solve my issue. angular.module("TeamSportApp", []) .controller('LedgerCtl', function($scope, LedgerService) { $scope.ledger = []; //

MGSplitViewController Not As Root

喜夏-厌秋 提交于 2019-12-08 06:40:44
问题 I need to use an MGSplitViewController because of it's ability to show the master view controller in the portrait mode. However, before displaying my split view, I need to display a login screen. Unfortunately I am unable to pop the view controller in fullscreen at startup because of some other methods that I have called! Below, is my app delegate and detail view controller codes. Please note, that the selector methods prevent me from opening a modal! AppDelegate.h was constructed using

AngularJS notifying view of changes to model

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 06:18:47
问题 I'm trying to display the current time in a view based on a Javascript Date object in my controller. My controller looks like this: myApp.controller('DateCtrl', function($scope) { var date = new Date(); $scope.minutes = date.getMinutes(); $scope.hours = date.getHours(); $scope.seconds = date.getSeconds(); var updateTime = function() { var date2 = new Date(); $scope.minutes = date2.getMinutes(); $scope.hours = date2.getHours(); $scope.seconds = date2.getSeconds(); } $scope.clickUpdate =

How do you append a filter to the very end of a filter chain from a superclass?

倖福魔咒の 提交于 2019-12-08 05:36:15
问题 in rails when you register filters in abstract superclasses they come before the filters registered in the controller class. Say I wanted to execute a method called authenticate as a filter right at the end of the filter chain. The only way I can figure it out is to declare that before_filter as the last filter in all my controller classes (and there are many of them). Is there a way to declare this filter in the superclass and have it still be executed last? The reason I want it executed

Spring MVC Rest / JSON service

喜欢而已 提交于 2019-12-08 05:31:50
问题 I just tried adding this to my sample controller: @RequestMapping(value="/jsontest", method=RequestMethod.GET) public @ResponseBody User getUserAsJson() { User jsonUser = new User(); jsonUser.setFirstName("Mickey"); jsonUser.setLastName("Mouse"); jsonUser.setUsername("mmous"); return jsonUser; } However, visiting the /jsontest url ends on a 406 http error => not acceptable. So... what's the currently working method for producing "application/json" responses, instead of returning jsp/html

Pass variable to UI-bootstrap modal without using $scope

♀尐吖头ヾ 提交于 2019-12-08 05:28:37
问题 Since I am a beginner using AngularJS the $scope approach to pass data between different controllers and (in my case) a modal drives me crazy. Due to that reason, I googled around the web and found an interesting blogpost about passing data to a UI-bootstrap modal without using $scope . I had a deeper look at this blogpost and the delivered plunk which works pretty nice and started to adopt this to my own needs. What I want to achieve is to open a modal delivering an text input in which the