I'm currently facing an issue where I am attempting to send data from a controller to a directive in order to dynamically update rows in a table. However, despite my efforts, the table does not reflect any updates and there are no error messages displayed in the console.
Below is the HTML code snippet:
$<div ng-app="roleManagement" ng-controller="RoleManagementCtrl">
<h1> Role Management</h1><hr/>
<div class="container-fluid">
<form >
<div class="form-group row">
<button type="button" class="btn btn-primary col-md-1"
ng-click="query(roleId, userId)">Query</button>
<button type="button" class="btn btn-primary col-md-2 col-md-offset-
1">Edit Role</button>
</div>
<div class="form-group row">
<label class="col-md-1" >Role ID</label>
<select class="col-md-2 col-md-offset-1" ng-model="roleId">
<option></option>
<option ng-repeat="roleID in roleIDS | unique :roleID">{{roleID}}</option>
</select>
</div>
<div class="form-group row">
<label class="col-md-1">User ID</label>
<select class="col-md-2 col-md-offset-1" ng-model="userId">
<option></option>
<option ng-repeat="userID in userIDS | unique :userID">{{userID}}
</option>
</select>
</div>
</form>
</div>
<hr/>
<div ng-controller="RoleManagementCtrl">
<my-table users = 'users'></my-table>
</div>
</div>
The following depicts my controller and directive setup. My intention is to pass on $scope.users via the controller to the directive:
$'use strict';
angular.module('roleManagement', ['angularUtils.directives.dirPagination'])
.controller('RoleManagementCtrl', ['$scope', '$http', 'localStorageService',
function($scope, $http, localStorageService) {
var init = function () {
$http({
method: 'GET',
url: 'http://172.16.0.26:7001/Taisys_Server_Current/getAllRoles',
headers: {'X-Auth-Token': localStorageService.get('jwtTokens')}
}).success(function (response) {
$scope.roleIDS = response;
});
$http({
method: 'GET',
url: 'http://172.16.0.26:7001/Taisys_Server_Current/getAllUsers',
headers: {'X-Auth-Token': localStorageService.get('jwtTokens')}
}).success(function (response) {
$scope.userIDS = response;
});
};
init();
$scope.query = function (roleId, userId) {
...
);
element.replaceWith(html);
}
}
});