How to pass a fields variable to directive in ng route configuration, Or in another phase?
.when('/test',{template:"<my-directive fields=field></my-directive>"})
How to assign param to directive in routing phase?
How to pass a fields variable to directive in ng route configuration, Or in another phase?
.when('/test',{template:"<my-directive fields=field></my-directive>"})
How to assign param to directive in routing phase?
Make sure to include your directive when defining the module dependencies:
var app = angular.module('sampleApp', [
'ngRoute',
'myDirective' // here, you need to include your directive module
]);
Then, define your routes:
app.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', { template: "This is the default Route" })
.when('/test', {
template: '<my-directive fields="field"></my-directive>',
controller: 'testController'
})
.otherwise({ redirectTo: '/' });
}]);
And a controller:
app.controller('testController', ['$scope', function($scope) {
$scope.field = { your: "data here" };
}]);