locked
Angular and Razor RRS feed

  • Question

  • User1783162757 posted

    I have been having trouble getting angular to work with Razor and webmatrix.  Can someone point me in the right direction?

    Thanks!

    Thursday, April 30, 2015 2:08 PM

Answers

  • User-821857111 posted

    You don't need to use @Href, but it is a Razor function that evaluates the relative path ~/Content/js/angular.min.js, and converts it to a URL. Since version 2 of Web Pages, Razor will see the tiled ( ~ ) and automatically invoke the Href method so this will work:

    <script src="~/Content/js/angular.min.js"></script>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 2, 2015 3:01 AM

All replies

  • User1783162757 posted

    This seems to have fixed it...  New to razor so I guess I have to add a few things.

    <script src="@Href("~/Content/js/angular.min.js")"></script>

    So adding the @HREF stuff forces it to evaluate the angular script as html or javascript???

    Thursday, April 30, 2015 3:18 PM
  • User379720387 posted

    No, this just tells it where is can find the angular.min.js file.

    You still need to make the call markup to angular specific functionality.

    Thursday, April 30, 2015 10:17 PM
  • User-821857111 posted

    You don't need to use @Href, but it is a Razor function that evaluates the relative path ~/Content/js/angular.min.js, and converts it to a URL. Since version 2 of Web Pages, Razor will see the tiled ( ~ ) and automatically invoke the Href method so this will work:

    <script src="~/Content/js/angular.min.js"></script>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 2, 2015 3:01 AM