I recently started with Angular , so I have a few questions.
My problem:
I created a directive that I will use in many "pages" with different controllers in each situation, for example.
Now I can dynamically configure the controller, this problem is solved!
But in each instance the directive, I want to determine which variable is to be changed in the controller, for example ng-model. If I put directly in the tag in the template, it works, but I need it dynamically.
DIRECTIVE
app.directive('mySelectPicker', function () {
var ddo = {};
ddo.restrict = 'E';
ddo.templateUrl = 'js/directives/views/my-select-picker.html';
ddo.scope = {};
ddo.controller = "@";
ddo.name = "controllerName";
return ddo;
});
MY-SELECT-PICKER.HTML:
OBS1: (ng-repeat times)
OBS2: ng-model select, , !
<select>
<option value="{{time.value}}" ng-repeat="time in times" >{{time.text}}</option>
</select>
CONTROLLER
app.controller('MyController', function($scope, moment){
$scope.times = [];
$scope.val1 = '';
$scope.val2 = '';
});
:
<my-select-picker controller-name="MyController" **ng-model="val1"**></my-select-picker>
<my-select-picker controller-name="MyController" **ng-model="val2"**></my-select-picker>
ng-model <my-select-picker>, , . ?