Most of the examples of AngularJS controllers I've seen usually have a single action method that works everything for presentation. On the other hand, in controllers using the MVC pattern, and not in AngularJS MVW, there are usually several action methods for each controller, but this is not like AngularJS.
It is provided that any number of methods that execute the behavior can be associated with the number $ (or some other object), but still this is similar to the MVC action methods, since they do not automatically accept direct route input.
I am interested because I am trying to convert an existing ASPP MVC application to angular and I am trying to solve the best organizational failure for controllers.
Are my various assumptions correct?
Do AngularJS controllers use more than one action / configuration method?
Are angular controllers ever broken into separate actions? Or does the angular controller have more or less one action, although routing and presentation may differ?
Update :
The requested example is the AngularJS controller:
myApp.controller('DoubleController', ['$scope', function($scope) {
$scope.double = function(value) { return value * 2; };
}]);
An example of an Asp.Net MVC controller:
public class CardController : Controller
{
private readonly IService _service;
public CardController(IService service)
{
_service = service;
}
public ActionResult Index(Guid gameId)
{
var model = _service.GenerateCardBuyDisplayModel(gameId);
return View(model);
}
public ActionResult BuyCards(ExecuteBuyModel input)
{
_service.ExecuteBuy(input.GameId, input.CardsToBuy);
return RedirectToAction("Index", "Game", new { id = input.GameId});
}
}
Example Ruby on Rails controller:
class ClientsController < ApplicationController
def index
if params[:status] == "activated"
@clients = Client.activated
else
@clients = Client.inactivated
end
end
def create
@client = Client.new(params[:client])
if @client.save
redirect_to @client
else
render "new"
end
end
end
, AngularJS /, MVC Asp.net . Ruby of rails , . MVC Asp.net( Ruby on Rails) , MVC. AngularJS , action/constructor, - . , Asp.net MVC , , -. / AngularJS.