Skip to content

Instantly share code, notes, and snippets.

@kneerunjun
Last active November 17, 2015 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kneerunjun/ebbe80abb3919d814f72 to your computer and use it in GitHub Desktop.
Save kneerunjun/ebbe80abb3919d814f72 to your computer and use it in GitHub Desktop.
  <emp-label append-text="Text that you want to appear before the emp details: "></emp-label>
(function () {
    var empLabel = angular.module("enggedu").directive("empLabel", function () {
        return {
            restrict: "E",
            replace: true,
            scope: true,
            require: "^urlEmployee",
            templateUrl:"/app/directives/emplabel/emplabel.html",
            compile:function (elem, attrs) { 
                return {
                    pre: function (scope, elem, attrs) {
                        //this is where it gets all the appending text
                        scope.appendText= $(elem[0]).attr("append-text");
                        console.log("emplabel/pre function: we have the value of the text that is to be appended:" + scope.appendText);
                    },
                    post: function (scope, elem, attrs, parentController) {
                        console.log("emp-label/controller: do we have access to the scope on the main controller ?");
                        console.log("emp-label/controller: value of the emp email " + scope.emp.email);
                    }
                }
            },
            controller: function ($scope) {
                
            }
        }
    })
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment