0

I'm new in Node JS and Angular. Making a small test project that retrieves rules data from a restful api, the api works fine... I load all rules in rules.html but each one of them has a link to view the details which is my pain right now... according to the tutorial the link should point to /rules/details/{{rule._id}}

app.js

var app = angular.module('SmartSoftApp', ['ngRoute']);

app.config(['$routeProvider', function($routeProvider){   
    $routeProvider.when('/rules/details/:id', {
        moduleId: app.id, 
        templateUrl: '/views/ruleDetails.html',
        controller: 'RulesController'
    })
})

The issue here is, when I click the link, I get Cannot GET /rules/details/[id]. I can change the link to point the html file instead but I assume that's not how it works.

I'm new at this so I appreciate if someone can guide me through this

Thanks

1
  • this question belong to angularjs tag, not angular tag, please update your post tag. Commented Apr 15, 2017 at 15:47

1 Answer 1

0

The link should be "#/rules/details/{{rule._id}}"

<a href="#/rules/details/{{rule._id}}">Link</a>

Also as you are binding values from your model you should use ng-href.

https://docs.angularjs.org/api/ng/directive/ngHref

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks for your response, I tried that but it does nothing... another thing, when I hover the link shown is ...localhost:3000/views/rules.html#/rules/details... is that correct?
No. The "rules.html" shouldn't be there.
Problably you are using the link in the page accessed directly by the html file. Use the route to get to the page where the link is and it will be correct.
Ohh that's a good hint, let me check that and get back to you
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.