Skip to content

Instantly share code, notes, and snippets.

@fastcodecoq
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save fastcodecoq/a8fd02211f970f100e31 to your computer and use it in GitHub Desktop.

Select an option

Save fastcodecoq/a8fd02211f970f100e31 to your computer and use it in GitHub Desktop.
<div class="input-group">
<select required tabindex="2" chosen class="chosen-select form-control {{aclass}}" style="{{astyle}}" tabindex="{{tabIndex}}" ng-model="ngModel" ng-options="value.name for value in {{ngModel}} track by value._id">
</select>
<div class="input-group-btn">
<button id="quickaddd" data-toggle="tooltip" data-placement="top" title="{{atitle}}" data-original-title="Crear uno nuevo" class="btn btn-primary"><i class="fa fa-plus-square-o"></i>
</button>
</div>
</div>
function connectedField(){
function Ctrl($scope, $rootScope, API){ //API viene de los servicios
// do the magic
API
[$scope.ngEntity]() //entity debe ser similar a su referencia en apiFactory, método que esta en el archivo controllers
.get()
.success(function(rs){
$scope[$scope.ngModel] = rs.data;
console.log($scope[$scope.ngModel])
});
}
function Link(scope, element, attrs){
//do something linking
}
return {
restrict : 'AE',
scope :
{
ngModel : '@',
ngEntity : '@',
aclass : '@',
astyle : '@',
tabindex : '@'
},
templateUrl : 'views/connected_field.html',
controller : Ctrl,
link : Link
}
}
angular
.module('inspinia')
.directive('ngConnected', connectedField);
<ng-connected ng-model="miempresa" ng-entity="empresa"></ng-connected>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment