Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5.1 > BOOK: Professional ASP.NET MVC 5
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 5
This is the forum to discuss the Wrox book Professional ASP.NET MVC 5 by Jon Galloway, Brad Wilson, K. Scott Allen, David Matson; ISBN: 978-1-118-79475-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 8th, 2017, 05:20 AM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default hash sign # not routing

I'm using VS Community Edition, AngularJS 1.6 and Google Chrome as my browser.

In Chapter 12 the re-routing using Angular with a hash sign isn't working. There are no errors it just doesn't produce the details view on clicking the a-link.

HTML Code:
            <td>{{movie.Title}}</td>
            <td>
                <a href="#/details/{{movie.Id}}">Details</a>
            </td>
Code:
            <td>{{movie.Title}}</td>
            <td>
                <a href="#/details/{{movie.Id}}">Details</a>
            </td>[/html]
        $routeProvider
            .when("/list",
                { templateUrl: "/client/views/list.html" })
            .when("/details/:id",
                { templateUrl: "/client/views/details.html" })
            .otherwise(
                { redirectTo: "/list" }
            );
        //$routeProvider.html5Mode(true);
As you can see, I attempted html5Mode and removing the hash-sign but the method isn't found.

(A side issue is that I also cannot use the $http.get() shorthand as this method isn't found either.)

Thank you.
Reply With Quote
  #2 (permalink)  
Old February 28th, 2017, 03:44 PM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2017
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try using this instead. Note the additional ! character. This worked for me although I have no idea why.
HTML Code:
<a class="btn btn-default" href="#!/details/{{movie.Id}}">Details</a>
Also, the book is using $http.get().success();, but that is now deprecated. Try using something like this instead.
Code:
$http.get("/api/movie").then(
            function (response) { // success
                $scope.movie = response.data;
            },
            function (response) { // failure
                $scope.movie = response.data || "Fail";
            }
        );
Reply With Quote
  #3 (permalink)  
Old February 28th, 2017, 04:00 PM
Registered User
Points: 11, Level: 1
Points: 11, Level: 1 Points: 11, Level: 1 Points: 11, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your post. I'll try this at the weekend.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hash and un-hash Mattt C# 1 August 25th, 2009 11:40 AM
URL Routing elwappo ASP.NET 3.5 Professionals 2 June 11th, 2009 01:20 AM
URL Routing elwappo ASP.NET 2.0 Professional 4 May 26th, 2009 04:27 PM



All times are GMT -4. The time now is 11:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.