角度转换和ng-repeat

时间:2015-10-07 15:15:05

标签: angularjs angularjs-directive

如何使用MyDirective作为指令来转换以下代码!

<div my-directive title="test">
    <div ng-repeat="test in dataInController">
          <div ng-bind="test.title"></div>
    </div>
</div>

我想将元素的输出改为

<div>
    <div class="header">test</test>
    <div class="content">
        <!-- original html content of the directive -->
        <div ng-repeat="test in dataInController">
            <div ng-bind="test.title"></div>
        </div>
    </div>
</div>

我试图玩转运而没有运气!

任何帮助将不胜感激!

修改 试过Tomer solution没有运气

日Thnx c_bb

2 个答案:

答案 0 :(得分:0)

请试试这个:

public void Intercept(IInvocation invocation)
{
  var methodReference = Guid.NewGuid();
  Console.WriteLine($"Calling {invocation?.Method?.DeclaringType?.Name}.{invocation?.Method?.Name} : {methodReference}");

  var startNew = Stopwatch.StartNew();

  invocation.Proceed();
  invocation.ReturnValue = WatchAsync(methodReference, startNew, (Task)invocation.ReturnValue);
}

private static async Task WatchAsync(Guid methodReference,
    Stopwatch stopwatch, Task methodExecution)
{
  try
  {
    await methodExecution.ConfigureAwait(false);
  }
  finally
  {
    stopwatch.Stop();
    Console.WriteLine($"{methodReference} : Done, time taken: {stopwatch.ElapsedMilliseconds}ms");
  }
}

答案 1 :(得分:-1)

参见本准则:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Answer = random.Next(0, 99);
        User_Guess = 0;
        Guess_num = 0;
    }

    Random random = new Random();
    int Answer;
    int User_Guess;
    int Guess_num;

    private void Guess_btn_Click(object sender, EventArgs e)
    {
        try
        {
            User_Guess = int.Parse(Guess_txtbx.Text);
            Guess_num++;

            if (User_Guess == Answer)
            {
                MessageBox.Show("Your answer is correct! It took you " + Guess_num + "number of guesses.");
                Guess_num = 0;
                return;
            }

            MessageBox.Show(String.Format("Your answer is too {0}, try again.", User_Guess > Answer ? "High" : "Low"));
            Guess_txtbx.Clear();
            Guess_txtbx.Focus();
         }

        catch (Exception ex)
         {
            MessageBox.Show(ex.Message);
         }
    }
}

see this code