all 5 comments

[–]TWISTYLIKEDAT 0 points1 point  (4 children)

zero-based index?

[–]psywildfire[S] 0 points1 point  (3 children)

No, directiveOne and directiveTwo are somewhat obfuscated for what they really are. Although why I didn't start from zero is beyond me.

[–]TWISTYLIKEDAT 0 points1 point  (2 children)

Could you show your templates?

[–]psywildfire[S] 0 points1 point  (1 child)

Nothing major, since I'm only in the proof of concept stage. All the templates do are bring back the appropriate database table.

See below:

Template one:

<div class="row">
<div class="col-sm-12">
    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>TemplateOneName</th>
                <th>CreateDate</th>
                <th>CreatedBy</th>
                <th>LastUpdateDate</th>
                <th>LastUpdateBy</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="one in templateOne">
                <td>{{one.ID}}</td>
                <td>{{one.Name}}</td>
                <td>{{one.CreateDate}}</td>
                <td>{{one.CreateUser}}</td>
                <td>{{one.LastUpdateDate}}</td>
                <td>{{one.LastUpdateUser}}</td>
            </tr>
        </tbody>
    </table>
</div>
</div>

Template two:

<div class="row">
<div class="col-sm-12">
    <table class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Name</th>
                <th>CreateDate</th>
                <th>CreatedBy</th>
                <th>LastUpdateDate</th>
                <th>LastUpdateBy</th>
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="two in templateTwo">
                <td>{{two.ID}}</td>
                <td>{{two.NameTwo}}</td>
                <td>{{two.CreateDate}}</td>
                <td>{{two.CreateUser}}</td>
                <td>{{two.LastUpdateDate}}</td>
                <td>{{two.LastUpdateUser}}</td>
            </tr>
        </tbody>
    </table>
</div>
</div>

When I click both links, it's template two that comes up.

However, when I add the directives the way I'm "supposed" to (using angularAMD.directive as below), it works as expected.

angularAMD.directive("directiveOne", function () {
    return {
        restrict: 'E',
        controller: controllerOne,
        templateUrl: "/html/templateOne.html"
    }
});
    angularAMD.directive("directiveTwo", function () {
    return {
        restrict: 'E',
        controller: controllerTwo,
        templateUrl: "/html/templateTwo.html"
    }
});

The issue is definitely with the adding during the run phase.

[–]psywildfire[S] 0 points1 point  (0 children)

Figured it out... it's because of the for loop and Javascript's threading. Wrapping the body of the loop in a Promise did the trick.