DirectivaTest2

by cyberwombat

HTML

<div ng:app="hifiDate">
 <div ng-controller="Ctrl2">
   <div ng-repeat="res in resources"><ng-file-chooser file-src="res.name"/></div>
     <ng-file-chooser file-src="resources[0].name"></ng-file-chooser>
    <pre>{{resources}}</pre>
 </div>
</div>

CSS

</style><script src="http://docs-next.angularjs.org/angular-1.0.0rc2.min.js"></script>
<style>

JavaScript

function Ctrl2($scope) {
    $scope.resources = [{name: 'res1'}, {name:'res2'}];
}
hifidate = angular.module('hifiDate', []);

hifidate.directive("ngFileChooser", function ($http) {
    var directiveDefinitionObject = {
        restrict: 'E',
        replace: true,
        scope: { fileSrc: 'accessor' },
        template: '<div><input type="text" ng:model="fileSrc()"/><input type="submit"  value=" ... "/></div>',
        link: function (scope, element) {
            $(element).find('input').eq(1).bind('click', function () {
                scope.$apply( function() {scope.fileSrc("David");});
            });
        }
    };
    return directiveDefinitionObject;
});