Javascript 角基础指令 我使用角基础(),它利用角度指令来实现诸如Modals、Tabs和其他前端服务之类的基础事务。

Javascript 角基础指令 我使用角基础(),它利用角度指令来实现诸如Modals、Tabs和其他前端服务之类的基础事务。,javascript,angularjs,zurb-foundation,Javascript,Angularjs,Zurb Foundation,我遇到的问题是,所有指令都预先填充了服务器上不存在的“templateUrl”属性。此外,由于这是一个使用Bower管理的外部依赖项,因此我无法手动更新库。我从库中取出以下指令: angular.module('mm.foundation.tabs', []) .directive('tabset', function() { return { restrict: 'EA', transclude: true, replace:

我遇到的问题是,所有指令都预先填充了服务器上不存在的“templateUrl”属性。此外,由于这是一个使用Bower管理的外部依赖项,因此我无法手动更新库。我从库中取出以下指令:

angular.module('mm.foundation.tabs', [])
    .directive('tabset', function() {
      return {
        restrict: 'EA',
        transclude: true,
        replace: true,
        scope: {},
        controller: 'TabsetController',
        templateUrl: 'template/tabs/tabset.html',
        link: function(scope, element, attrs) {
          scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
          scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
          scope.type = angular.isDefined(attrs.type) ? scope.$parent.$eval(attrs.type) : 'tabs';
        }
      };
    })

从我的模块中,我声明对M.Funm模块的依赖性:

angular.module('foundationDemoApp', ['mm.foundation.tabs']).controller('TabsDemoCtrl', function ($scope) {
  $scope.tabs = [
    { title:"Dynamic Title 1", content:"Dynamic content 1" },
    { title:"Dynamic Title 2", content:"Dynamic content 2" }
  ];

  $scope.alertMe = function() {
    setTimeout(function() {
      alert("You've selected the alert tab!");
    });
  };
})
我目前正在使用Gulp和Gulp-html2js捆绑我的模板。在github自述中,他们提到了定制模板()关于$templateCache的一些内容,但此时我不确定如何将库中定义的templateUrl更改为模板的位置


对此,如有任何指导,将不胜感激

既然没有人回答,我就试一试,这可能会对你有所帮助,奥赛(请各位主持人注意,如果我错了,请随意删除我的答案)

如果
bower安装
ed库,这些模板应该在
bower\u组件/angular foundation
中的某个位置,您应该按照它们的示例获得如下内容:

html2js: {
  options: {
    base: '.',
    module: 'ui-templates',
    rename: function (modulePath) {
      var moduleName = modulePath.replace('bower_components/angular-foundation', '').replace('.html', '');
      return 'template' + '/' + moduleName + '.html';
    }
  },
  main: {
    src: ['bower_components/angular-foundation/**/*.html'],
    dest: '.tmp/ui-templates.js'
  }
}
//or in gulp
gulp.src('bower_components/angular-foundation/**/*.html')
  .pipe(html2js({
    outputModuleName: 'ui-templates'
  }))
  .pipe(concat('ui-templates.js'))
  .pipe(gulp.dest('./'))

既然没有人回答,我就试一试,它可能会对你有所帮助,奥赛(请注意,任何主持人,如果我错了,请随意删除我的答案)

如果
bower安装
ed库,这些模板应该在
bower\u组件/angular foundation
中的某个位置,您应该按照它们的示例获得如下内容:

html2js: {
  options: {
    base: '.',
    module: 'ui-templates',
    rename: function (modulePath) {
      var moduleName = modulePath.replace('bower_components/angular-foundation', '').replace('.html', '');
      return 'template' + '/' + moduleName + '.html';
    }
  },
  main: {
    src: ['bower_components/angular-foundation/**/*.html'],
    dest: '.tmp/ui-templates.js'
  }
}
//or in gulp
gulp.src('bower_components/angular-foundation/**/*.html')
  .pipe(html2js({
    outputModuleName: 'ui-templates'
  }))
  .pipe(concat('ui-templates.js'))
  .pipe(gulp.dest('./'))

既然没有人回答,我就试一试,它可能会对你有所帮助,奥赛(请注意,任何主持人,如果我错了,请随意删除我的答案)

如果
bower安装
ed库,这些模板应该在
bower\u组件/angular foundation
中的某个位置,您应该按照它们的示例获得如下内容:

html2js: {
  options: {
    base: '.',
    module: 'ui-templates',
    rename: function (modulePath) {
      var moduleName = modulePath.replace('bower_components/angular-foundation', '').replace('.html', '');
      return 'template' + '/' + moduleName + '.html';
    }
  },
  main: {
    src: ['bower_components/angular-foundation/**/*.html'],
    dest: '.tmp/ui-templates.js'
  }
}
//or in gulp
gulp.src('bower_components/angular-foundation/**/*.html')
  .pipe(html2js({
    outputModuleName: 'ui-templates'
  }))
  .pipe(concat('ui-templates.js'))
  .pipe(gulp.dest('./'))

既然没有人回答,我就试一试,它可能会对你有所帮助,奥赛(请注意,任何主持人,如果我错了,请随意删除我的答案)

如果
bower安装
ed库,这些模板应该在
bower\u组件/angular foundation
中的某个位置,您应该按照它们的示例获得如下内容:

html2js: {
  options: {
    base: '.',
    module: 'ui-templates',
    rename: function (modulePath) {
      var moduleName = modulePath.replace('bower_components/angular-foundation', '').replace('.html', '');
      return 'template' + '/' + moduleName + '.html';
    }
  },
  main: {
    src: ['bower_components/angular-foundation/**/*.html'],
    dest: '.tmp/ui-templates.js'
  }
}
//or in gulp
gulp.src('bower_components/angular-foundation/**/*.html')
  .pipe(html2js({
    outputModuleName: 'ui-templates'
  }))
  .pipe(concat('ui-templates.js'))
  .pipe(gulp.dest('./'))

有了$templateCache,我认为用自己的模板替换模板是可能的

对于选项卡:


使用$templateCache,我认为可以这样用自己的模板替换模板

对于选项卡:


使用$templateCache,我认为可以这样用自己的模板替换模板

对于选项卡:


使用$templateCache,我认为可以这样用自己的模板替换模板

对于选项卡:


嘿,谢谢你们的回答,事实上你们都是对的

我的问题是,我一直在逆向思考解决方案。在本例中,我需要重命名正在编译的模板的名称,而不是替换每个指令的templateUrl参数。例如

我正在使用gulp和html2js捆绑我的模板文件。导入angular foundation之前,我的模板任务如下所示:

gulp.task('templates', function (cb) {

           gulp.src('path/to/tempalates/**/*.html')
             .pipe(html2js({
               outputModuleName: 'my.templates',
               base: './src/web/',
             }))
             .pipe(concat('templates.js'))
             .pipe(insert.prepend("var angular = require('angular');"))
             .pipe(gulp.dest('./src/web/'))
             .on('end', done);
         };
});
我继续从angular foundation github存储库上传了html模板目录,并将其放在路径“path/to/foundation/template”中。然后,我更新了templates gulp任务,以便它将“path/to/foundation/template”路径重命名为指令中已编码的路径。例如,如果指令要求templateUrl为“template/tab/tabs.html”,而实际模板的位置为“path/to/foundation/template/tab/tabs.html”,则重命名函数将用空字符串替换“path/to/foundation”,以在生成期间生成路径“template/tab/tabs.html”。我的最后一次吞咽任务现在看起来像:

gulp.task('templates', function (cb) {
           gulp.src('path/to/tempalates/**/*.html','path/to/foundation/template/**/*.html'])
             .pipe(html2js({
               outputModuleName: 'my.templates',
               base: './src/web/',
               rename : function (modulePath) {
                  var moduleName = modulePath.replace('path/to/foundation/', '').replace('.html', '');
                  return moduleName + '.html';
                }
             }))
             .pipe(concat('templates.js'))
             .pipe(insert.prepend("var angular = require('angular');"))
             .pipe(gulp.dest('./src/web/'))
             .on('end', done);
         };
});
所以现在我所有的模板都是按照angular foundation希望它们的路径构建的,我不会在运行时试图管理模板路径


我希望这能帮助别人

嘿,谢谢你们的回答,事实上你们都是对的

我的问题是,我一直在逆向思考解决方案。在本例中,我需要重命名正在编译的模板的名称,而不是替换每个指令的templateUrl参数。例如

我正在使用gulp和html2js捆绑我的模板文件。导入angular foundation之前,我的模板任务如下所示:

gulp.task('templates', function (cb) {

           gulp.src('path/to/tempalates/**/*.html')
             .pipe(html2js({
               outputModuleName: 'my.templates',
               base: './src/web/',
             }))
             .pipe(concat('templates.js'))
             .pipe(insert.prepend("var angular = require('angular');"))
             .pipe(gulp.dest('./src/web/'))
             .on('end', done);
         };
});
我继续从angular foundation github存储库上传了html模板目录,并将其放在路径“path/to/foundation/template”中。然后,我更新了templates gulp任务,以便它将“path/to/foundation/template”路径重命名为指令中已编码的路径。例如,如果指令要求templateUrl为“template/tab/tabs.html”,而实际模板的位置为“path/to/foundation/template/tab/tabs.html”,则重命名函数将用空字符串替换“path/to/foundation”,以在生成期间生成路径“template/tab/tabs.html”。我的最后一次吞咽任务现在看起来像:

gulp.task('templates', function (cb) {
           gulp.src('path/to/tempalates/**/*.html','path/to/foundation/template/**/*.html'])
             .pipe(html2js({
               outputModuleName: 'my.templates',
               base: './src/web/',
               rename : function (modulePath) {
                  var moduleName = modulePath.replace('path/to/foundation/', '').replace('.html', '');
                  return moduleName + '.html';
                }
             }))
             .pipe(concat('templates.js'))
             .pipe(insert.prepend("var angular = require('angular');"))
             .pipe(gulp.dest('./src/web/'))
             .on('end', done);
         };
});
所以现在我所有的模板都是按照angular foundation希望它们的路径构建的,我不会在运行时试图管理模板路径


我希望这能帮助别人

嘿,谢谢你们的回答,事实上你们都是对的

我的问题是,我一直在逆向思考解决方案。在本例中,我需要重命名正在编译的模板的名称,而不是替换每个指令的templateUrl参数。例如

我正在使用gulp和html2js捆绑我的模板文件。导入angular foundation之前,我的模板任务如下所示:

gulp.task('templates', function (cb) {

           gulp.src('path/to/tempalates/**/*.html')
             .pipe(html2js({
               outputModuleName: 'my.templates',
               base: './src/web/',
             }))
             .pipe(concat('templates.js'))
             .pipe(insert.prepend("var angular = require('angular');"))
             .pipe(gulp.dest('./src/web/'))
             .on('end', done);
         };
});
我继续从angular foundation github存储库上传了html模板目录,然后