Skip to content

Instantly share code, notes, and snippets.

@kneerunjun
Last active November 15, 2015 13:54
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/143272bc25071b6b1e48 to your computer and use it in GitHub Desktop.
Save kneerunjun/143272bc25071b6b1e48 to your computer and use it in GitHub Desktop.
var myapp = angular.module("myapp",[]).config(function($routeProvider){
  $routeProvider
  //this is the just the login view
  .when("/login", {templateUrl:"/app/login/login.html", controller:"loginController"})
  //this would devise the help page for the login, notice how the help is placed in a position for the virtual folders
  .when("/login/html", {templateUrl:"/app/login/help.html", controller:""}) 
});

Help doucmentation would be in the same virtual folder as that of the view. Available as the progressive url from the view. Now what we need is a directive that would be manifested on each page so as to move the absolute url.

Here is what the directive might look like

(function () {
    var helpPage = angular.module("enggedu").directive("helpPage", function () {
        return {
            restrict: "E",
            replace: true,
            templateUrl:"/app/directives/helppage/helppage.html",
            scope: {

            },
            compile:function (tElem, attrs) {
                return {
                    pre: function (scope, element, attributes) {
                        $(element[0]).popover({
                            trigger: "hover",
                            placement: "left",
                            content:"help me"
                        })
                    }
                }
            },
            controller: function ($scope, $location, $window) {
                $scope.onHelp = function () {
                    $window.open($location.absUrl() + "/help");
                    //$window.location.href='/empstructure/help';//moving to the help page for the emptructure 
                }
            }
        }
    })
})();

Template could be anything that you wish that appears as a link to the help page of the view. Observe the controller function 'onHelp' - this uses the current absolute location to navigate to the help page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment