locked
Trying to convert razor code to Angular! RRS feed

  • Question

  • User1421620300 posted

    Question: Is their a rule when doing a conversion to CRUD model template code to combine with Angular functionality, or Can the CRUD template model code be converted to Angular is this wise business or should i try it another way around? Is this good practice or even possible for starters??

    CRUD view template create:

    @using (Html.BeginForm())
    {
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
    <h4>Coach</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
    @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
    @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
    @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
    </div>
    </div>

    <div class="form-group">
    @Html.LabelFor(model => model.TeamId, "TeamId", htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
    @Html.DropDownList("TeamId", null, htmlAttributes: new { @class = "form-control" })
    @Html.ValidationMessageFor(model => model.TeamId, "", new { @class = "text-danger" })
    </div>

    Sunday, November 25, 2018 7:47 PM

Answers

  • User61956409 posted

    Hi Markus33,

    As far as I know, there are not any existing rules for converting MVC view template to Angular.

    To achieve your requirement: implement CRUD functionality with Angular, you could create services to implement these features, and then you can import and use your services in your Angular classes or components.

    Besides, for data/input validation, you can use client-side form validation to achieve it.

    For more information about Angular, please check Getting started with Angular.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 26, 2018 3:23 AM

All replies

  • User61956409 posted

    Hi Markus33,

    As far as I know, there are not any existing rules for converting MVC view template to Angular.

    To achieve your requirement: implement CRUD functionality with Angular, you could create services to implement these features, and then you can import and use your services in your Angular classes or components.

    Besides, for data/input validation, you can use client-side form validation to achieve it.

    For more information about Angular, please check Getting started with Angular.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 26, 2018 3:23 AM
  • User1421620300 posted

    Hello Fei Han, would it be possible for you to help me with clarification on this topic. And possibly send me the links to some resources maybe! Thanks, Markus.

    Wednesday, December 5, 2018 6:28 PM