javascript - Angularjs directive not showing -
i started angularjs , trying build directive.
js file:
var app = angular.module('mycars',['ngresource']); app.controller('carcontroller', function (post) { var b = post.query(function () { console.log(all); }); this.cars = b; }); app.directive("carcritics", function () { return { restrict: 'e', templateurl: '~/views/home/car-critics.cshtml' }; });
in cshtml file looks this:
<car-critics></car-critics>
i have read lots of documentations in internet directives , can´t see doing wrong. anytime start application part in directive isn´t showing. appriciate type of help.
you dont straight away grab .cshtml views folder. must create actionresult , return "car-critics.cshtml", so:
public class homecontroller { public actionresult carcritics() { return view("car-critics"); } }
and directive should be:
app.directive("carcritics", function () { return { restrict: 'e', templateurl: '/home/carcritics' }; });
Comments
Post a Comment