【问题标题】:Show form using custom directive - AngularJS使用自定义指令显示表单 - AngularJS
【发布时间】:2014-07-28 07:29:47
【问题描述】:

我有一个带有 ng-click 功能的按钮。当我单击按钮时,它应该显示使用自定义指令在 templateUrl 中编码的表单。

我应该使用哪个函数来换屏?

Plunker:http://plnkr.co/edit/oxyOJ0XFDlZsLsnCegsI?p=preview

carVarApp.directive('dataEntry', function() {
      return {
      restrict: 'E',
      controller : function($scope)
      {
                         $scope.onClickEntry = function () {

                         $scope.formModel = {};
                       };
                   },
      templateUrl: 'dataEntry.html'
    };

【问题讨论】:

    标签: angularjs angularjs-directive angularjs-scope angularjs-routing angularjs-ng-click


    【解决方案1】:

    您不需要自定义指令来显示隐藏自定义 url..

    <div ng-show="showForm">
      <div ng-include src="{{templateUrlPath}}"></div>
    </div>
    

    【讨论】:

    • 如果有帮助,您能否接受/投票赞成答案??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-03
    • 1970-01-01
    • 2018-03-24
    • 2017-12-06
    • 1970-01-01
    • 2014-06-24
    相关资源
    最近更新 更多