angularjs routing - pass parameters to angular js directive partial view -
I have an MVC application that is using angular JSS. I have a primary navigation and secondary navigation. I am using ngRoute for primary navigation. I have instructed the secondary navigation template that I can use it in all other pages. The template used in the directive requires some input parameters.
Routing code:
myApp.config (['$ routeProvider', function ($ migration provider) {$ routeProvider when ('/ secondary innovation / 1', {templateUrl "Administration / page 1, resolved: {SecNavItems: [" $ http ", function ($ http) {var navItems = $ http.get ( '/ navigation / Sekenderianavigeshn', '{Params: {page name' Administration '}}); navItems.success (data) {return data;});}]}, controller:' AdminController '}}}]); var admin controller = function ($ scope, secant) {$ scope.secList = SecNavItems; } AdminController $ Inject = ["$ scope", "SecNavItems"]; MyApp.controller ("AdminController", AdminController); Web method code:
[HTTPGet] Public JSN Secondary Secondary Navigation (String PageName) {Dictionary & lt; String, string & gt; SecnavItems = new dictionary & lt; String, string & gt; (); SecnavItems.Add ("1", "Item1"); SecnavItems.Add ("2", "Item2"); var NavigationJetsJason = Jason (Sekenev Eats, Jason Yunus Behavior AloGuget); Return navigationem Jason; } page 1 is the code
& rdquo; Secondary navigation & gt; & Lt; / Secondary-navigation & gt; My Instruction is defined as follows: myApp.directive ("Secondary Navigation", Function () {Return {Restricted: 'E', Scope: {}, TemplateUrl: '/ navigation / secondary navigation'}}); Partial view template:
& lt; Div style = "height: 100%; width: 25%; background color: # 675c5c; color: white; float: left" & gt; @foreach (kwalpeier & lt; int, string> navItem in secList) {& lt; A href = "/ # / @ navItem.key" & gt; @ NavItem.value & lt; / A & gt; & Lt; Br / & gt; & Lt; Br / & gt; } & Lt; / Div & gt; & Lt; Div style = "height: 100%; width: 75%; float: correct" & gt; & Lt; / Div & gt; When I run the application, I do not see item 1 and item 2 in page 1, instead I see {{object}}
Please tell me what the parameters of the template used in the instructions I am passing.
Thank you.
What was wrong with the painted.
I wanted to make an html template of secondary navigation, then I included the web service call in the administrator controller, the object value was set to the webservice result and added the route provider.
Routing code:
myApp.config ([ '$ RouteProvider', function ($ Margpradata) {$ routeProvider. When ( '/ middle management / 1', { TemplateUrl: 'Administration / Page 1', Controller: 'AdminController'}}})); Var administrator controller = function ($ scope, $ http) {var navItems = $ http.get ( '/ navigation / Secondary Management', {params: {Pejanam: 'Administration'}}); NavItems.success (function (data) {$ scope.secList = data;}); }]},} Admin Controller. $ Inject = ["$ radius", "$ http"]; MyApp.controller ("AdminController", AdminController); My Instruction is defined as follows: myApp.directive ("Secondary Navigation", Function () {Return {Restricted: 'E', Scope: false, template reply: '/ navigation / secondary navigation'}});
Comments
Post a Comment