AngularJS开发WebApp的返回按钮-CSDN博客

82 阅读1分钟

HTML模板

<div class="head ta-c p-r">         //点击返回
    <span class="p-a c-w back-btn" ng-click="back()">&lt;</span>
    <span class="c-w" ng-bind="text">职位详情</span>
</div>

指令

'use strict'
angular.module('app').directive('appHeadBar',[function() {
    return {
        restrict: 'A',
        replace: true,
        templateUrl: 'view/template/headBar.html',
        scope: {
            text: '@'
        },link: function ($scope) {
            $scope.back = function() {
                window.history.back();  // 返回
            }
        }
    };
}]);