-1

Here is my Javascript file

(function () {
var app = angular.module('app');

var controllerId = 'officium.incident.list';
app.controller(controllerId, [
    '$scope', 'abp.services.incidentsystem.incident',
    function ($scope, officiumService) {
        var vm = this;

        alert('ssssss')

        officiumService.GetAllAssignedIncidents().success(function (data) {
            vm.incidents = data.incidents;
        });

    }
]);

The alert I have is called when I load my webpage so I know the JS and webpage are linked correctly. I don't understand however why my 'GetAllAssignedIncidents' function isn't working. I have put a breakpoint on ther server for when this method is called but it never hits it meaning there may be something wrong with my JS or webpage?

<div class="panel panel-default" ng-controller="officium.incident.list as vm">
<div class="panel-heading" style="position: relative;">

        <ul class="list-group" ng-repeat="incident in vm.incidents">
            <div class="list-group-item">
                <span ng-class="{'incident-description-active'">{{incident.IncidentDescription}}</span>
                <br />
                <span class="incident-assignedto">{{incident.LogID}}</span>
            </div>
        </ul>

</div>

My application service layer function.

    public async Task<GetAllAssignedIncidentsOutput> GetAllAssignedIncidents()
    {
        var incidents =  _incidentRepository.GetAllAssignedIncidents();

        return new GetAllAssignedIncidentsOutput
        {
            Incidents = AutoMapper.Mapper.Map<List<IncidentDto>>(incidents)
        };

    }

API controller Builder code

  public class OfficiumWebApiModule : AbpModule
  {
    public override void Initialize()
    {
        //This code is used to register classes to dependency injection system for this assembly using conventions.
        IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());

        //Creating dynamic Web Api Controllers for application services.

        DynamicApiControllerBuilder
            .ForAll<IApplicationService>(typeof(OfficiumApplicationModule).Assembly, "incidentsystem")
            .Build();
    }
8
  • You have syntax errors in you javascript, when page loads, Right -Click inspect element see the error in the console. Commented Jul 12, 2015 at 20:06
  • 2
    the way your code is written, you have abp.services.incidentsystem.incident being passed to the controller function as officumService. so you really are calling abp.services.incidentsystem.incident.GetAllAssignedIncidents(). does this function actually exist, and if it does, can you show it's code? Commented Jul 12, 2015 at 20:27
  • AS @Claies has said, how does your service look like? What's the error that you get on console?? Can you share these things? Commented Jul 12, 2015 at 20:33
  • @Claies You are right. I have deleted my answer Commented Jul 12, 2015 at 20:35
  • 1
    @ASPCoder1450 We need more information, like how you're referencing the above service code in your page. Assuming you're referencing it at all, Javascript, and Java are two, separate languages. Commented Jul 12, 2015 at 21:41

1 Answer 1

0

Most likely you're referencing the module where you actually want to reference the service. Also you are referencing an allready defined module 'app' instead of defining it, is that on purpose? I believe you want something more like this:

    var app = angular.module('app', ['abp.services.incidentsystem.incident']);

    var controllerId = 'officium.incident.list';
    app.controller(controllerId, [
      '$scope', 'officiumService',
      function($scope, officiumService) {
        var vm = this;

        alert('ssssss')

        officiumService.GetAllAssignedIncidents().success(function(data) {
          vm.incidents = data.incidents;
        });

      }
    ]);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.