Angular template + Controller Injection to Directive

http://angularjs.org/

by KevinIsNowOnline

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<script type="text/ng-template"  id="mySelect.html">    
    {{conds}}
     <select ng-options="obj as obj for obj in conds"></select>
    <select ng-model="wapak" ng-options="c.name for c in conds">
</script>


<div ng-controller="MyCtrl">
    
    
<form-input conds="conditions"></form-input>
    
</div>

JavaScript

var myApp = angular.module('myApp', []);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});


myApp.controller('MyCtrl', function ($scope) {
    $scope.name = 'Superhero';
    $scope.conditions = [
       {name:'black', shade:'dark'},
    {name:'white', shade:'light'},
    {name:'red', shade:'dark'}
    ];

});



myApp.directive('formInput', function () {
    return {
        restrict: 'E',
        templateUrl: 'mySelect.html',
        scope: {
            conds: '='
        }
    }
})