Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Essentially you need to re-use a template (/controller), and somehow pass options into it. You could probably do something with <code>ngInclude</code> and nesting controllers, but a way that is more friendly to more complex structure later is to create a custom directive. It depends a bit on your exact use-case, and exactly what you need to pass into it, but a simple version would be something like:</p> <pre><code>app.directive('formButtons', function() { return { restrict: 'E', scope: { 'localBack':'&amp;back', 'localSave':'&amp;save', 'localSaveAndContinue':'&amp;saveAndContinue' }, templateUrl: 'buttons.html' }; }); </code></pre> <p>With a template of</p> <pre><code>&lt;div&gt; &lt;button ng-click="localBack()"&gt;Back&lt;/button&gt; &lt;button ng-click="localSave()"&gt;Save&lt;/button&gt; &lt;button ng-click="localSaveAndContinue()"&gt;Save &amp;amp; Continue&lt;/button&gt; &lt;/div&gt; </code></pre> <p>The scope options with <code>&amp;</code> each define a function on the directive's scope, that evaluates contents of the attribute on the <code>&lt;form-buttons&gt;</code> element of that name in the parent scope. You can then use the directive as follows</p> <pre><code>&lt;form-buttons back="back(2)" save="save(2)" save-and-continue="saveAndContinue(2)"&gt;&lt;/form-buttons&gt; </code></pre> <p>which will get replaced by the template of the directive, and the function <code>save</code>, <code>back</code> and <code>saveAndContinue</code>, which are defined on the parent scope, will get called when clicking on the buttons in the template, passing the appropriate step number which can be used to customise behaviour.</p> <p>You can see a working example at <a href="http://plnkr.co/edit/fqXowQNYwjQWIbl6A5Vy?p=preview" rel="nofollow">http://plnkr.co/edit/fqXowQNYwjQWIbl6A5Vy?p=preview</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload